Passion Fruit!

Vrinda Vasavada's Blog

The Simple Basics of Complicated Data Structures!

on June 25, 2014

Objective: To understand the basics of  4 of the major data structures: arrays, stacks, queues, and binary trees.

Arrays:

An array is a way of storing data. It contains an index (a number for each value added to the array ) for example 0, 1, 2, 3… in this case. The values that are entered by the user are then added to the array (I, C, E…. The programmer can control the size of the array by placing the number in brackets after “array.” A simple diagram is shown below.

arrays

Stacks:

stacksA stack is one of the most important data structures. Stacks follow the LIFO principle (last-in-first-out), similar to a deck of cards.

 

 

 

 

 

Adding data to the top of the stack is called “push.”In the  diagram on the right, the letter “M” is being pushed into the stack.stacks push

 

 

 

 

 

 

stacks popRemoving a value from the stack is called “pop.” In this case, the letter “I” is being popped from the stack.

 

 

 

 

 

 

Queues: 

A queue is a data structure that follows the first-in-first-out principle. The process of removing an element is called dequeuing, and adding one is called enqueuing. Dequeuing occurs from the front end of the queue. Enqueuing occurs from the tail end of the queue.queue

Binary Trees:

A binary tree is a data type that is used for efficient sorting.

binary tree


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: