Basics of Data Structures

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is a data structure?

A data structure is a way of storing and retrieving data on your computer.

What is an array?

A data structure with one, or more, elements of the SAME type. The array itself is a fixed size, once its created it doesn't shrink or grow.

What is a linked list?

A linear data structure that is a list composed of node elements. The first node is the head of the list, and the last node is the tail. The advantage of the linked list is that its easy to store data in the middle of the list. This works because unlike an array the elements in the sequence are not stored continuously, each node is allocated separately (their actually storage in memory can be an any order). As long as you know the head, you can get to wherever you want.

What is a linear data structure?

A linear data-structure has sequentially arranged data items. The next time can be located in the next memory address. It is stored and accessed in a sequential manner. Array and list are example of linear data structure.

What is a Linked List and What are its types?

A linked list is a linear data structure (like arrays) where each element is a separate object. Each element (that is node) of a list is comprising of two items - the data and a reference to the next node.Types of Linked List : Singly Linked List : In this type of linked list, every node stores address or reference of next node in list and the last node has next address or reference as NULL. For example 1->2->3->4->NULL Doubly Linked List : Here, here are two references associated with each node, One of the reference points to the next node and one to the previous node. Eg. NULL<-1<->2<->3->NULL Circular Linked List : Circular linked list is a linked list where all nodes are connected to form a circle. There is no NULL at the end. A circular linked list can be a singly circular linked list or doubly circular linked list. Eg. 1->2->3->1 [The next pointer of last node is pointing to the first]

What is a list?

A list is an ordered collection of elements of a different data types. The number of elements in a list can change, contrast to the array. The two most common ways to implement a list would be a (1) linked list or a (2) array list.

What is a array list?

A list made up of one or more aways. If our list at any point exceeds the current array, what we can do is create a new larger array and copy over all the existing values. To avoid having to do this often, is to double the size of the array.

What is one of the simplest data structures?

A node. A node is a record with two elements; a value and a reference. The reference can point to another node. The purpose of the node is to represent a value but to associate the value to some other value (which the reference points to). Nodes are the building blocks of larger data structures, such as the linked list, and in some cases graphs and trees.

What are linear and non linear data Structures?

Linear: A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array. Linked List, Stacks and Queues Non-Linear: A data structure is said to be non-linear if traversal of nodes is nonlinear in nature. Example: Graph and Trees.

List some of the data structures you know?

Nodes, arrays, stacks, queues, trees, and graphs

What is an algorithm?

Operations that we can perform on data structures + a set of logical instructions for executing them.

What is the difference between primitive data types and composite data types?

Primitive data type: Individual numbers, characters, or booleans. Composite data type: the more sophisticated data types. strings, arrays(bundling of elements). However whether a data type is primitive or non-primitive, it depends whether or not if it was already built into the program or not. For example, a string could be a primitive data type (even though it doesn't necessarily have the characteristics of one)

What operations can be performed on Queues?

The below operations can be performed on a queue: enqueue() − adds an item to rear of the queue dequeue() − removes the item from front of the queue peek() − gives value of front item without removing it isempty() − checks if queue is empty isfull() − checks if queue is full

What operations can be performed on stacks?

The below operations can be performed on a stack: push() − adds an item to stack pop() − removes the top stack item peek() − gives value of top item without removing it isempty() − checks if stack is empty isfull() − checks if stack is full

What are common operations that can be performed on a data-structure?

The following operations are commonly performed on any data-structure: Insertion − adding a data item Deletion − removing a data item Traversal − accessing and/or printing all data items Searching − finding a particular data item Sorting − arranging data items in a pre-defined sequence

What is a queue?

(Linear Data Structure) A queue is an abstract data type with the collection of data kept in the order it was collected. You can only add from the back and remove from the front. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Think of a line at the store. The people "removed" from the line are the ones at the front and the people "added" to the lines are the ones at the back. Another example includes when students in a class need to print a graph they worked on, the printer prints it in order. The last person who clicked the print button, their graph would be printed out last. The key strokes are placed in a que like buffer. FIFO (First in, First Out). Queues are used when we need to work on data-items in exact sequence of their arrival. Every operating system maintains queues of various processes. Priority queues and breadth first traversal of graphs are some examples of queues.

What is a stack?

(Linear Data Structure) A stack is an abstract data type with elements of the SAME type. Data elements of the stack data structure can only be accessed (stored or retrieved) at one end of the stack in a LIFO (Last in First Out) manner. Its like a like a stack of plates (where you only stack plates at the top of the plate, and remove plates from the top of the plate). Another example includes navigating from page to page on a browser (google → fcusd → fhs → teacher → subject → chapter ) must click back button in order to move back. Stacks are used where we need to access data in the reverse order or their arrival. Stacks are used commonly in recursive function calls, expression parsing, depth first traversal of graphs etc.

How is an Array different from Linked List?

- The size of the arrays is fixed, Linked Lists are Dynamic in size. - Inserting and deleting a new element in an array of elements is expensive, Whereas both insertion and deletion can easily be done in Linked Lists. - Random access is not allowed in Linked Listed. - Extra memory space for a pointer is required with each element of the Linked list. - Arrays have better cache locality that can make a pretty big difference in performance.


Kaugnay na mga set ng pag-aaral

MGMT 2100: CH 9: Designing Adaptive Organizations

View Set

Anatomy and Physiology Chapter 6

View Set

MKTG 3310 Chapter 6-9 Practice Quiz ?'s

View Set