CS102-1 Prelim
if the front and rear are adjacent with each other.
How do you know if a circular queue is full??
Efficiency of a program depends upon the choice of data structure. Data structures are reusable. Data structure is specified by the ADT which provides a level.
Importance of Implementing Data Structures
priority number
In Priority Queue deletions are based on?
First In First Out
In Priority Queue, In the case of deleting element with the same priority what is done to break the tie?
priority number
In Priority Queue, a number is associated with every element of the queue?
tail
Unlike Singly Linked List, it has a ________ pointer that points at the end of the list.
Input-restricted deque, Output-restricted queue
Variations of Double Ended Queue
Push(element) Pop() Top()
What are the 3 operations used in Stack Data Structure?
principle of First In First Out(FIFO)
What does QUEUE DATA STRUCTURE follows?
data found or data is not in the list
What is the result of retrieving data in a singly linked list?
Scheduling and Processes
What job does Priority Queue used in Operating System?
waiting lists, buffers, and handling job scheduling.
What jobs can Priority Queue be used?
Last-In First -Out (LIFO) principle
What procedure does Stack follows?
If you know the maximum number of data that will be stored.
When does a circular queue can be advantageous?
The applications
Where does priority number comes from?
end of the list
Where does the new element is inserted in Queue Data Structure?
complex implementation of operations on linked list structure.
Disadvantage of Circular Linked List
1. Scan the postfix expression from left to right one token at a time. 2. If the scanned token is an operand, push it onto the stack. 3. If the scanned token is an operator, pop two operands from the stack. Perform the evaluation with the two operands using the scanned operator. Push the result to the stack. 4. Repeat steps 1 to 4 until all tokens are scanned. 5. Once all tokens are scanned, pop the stack to return the evaluation of the expression.
Evaluating Expression Algorithm
Array, Linked List, Stack, Queue
Examples of Linear Data Structure
Trees and Graphs
Examples of Non-Linear Data Structure
data, previous, and next pointer.
For a doubly linked list, each node has three fields
data and next pointer
For a singly linked list, each node has two fields
Postfix or reverse Polish notation
The operator is placed after the operands. For example, ab+.
Prefix or Polish notation
The operator is placed before the operands. For example, +ab.
Infix notation
The operator is placed in between the operands. For example, a +b.
edges
what do you call the link that connect nodes in a graph?
data organization management efficient access and modification functions or operations that can be applied to the data
what is a data structure?
NULL
what is set unto the pointer if it is the last node in a singly linked list?
Doubly Linked List
A data structure that consists of a sequence of elements each of which contains a reference to the previous and next elements in the list.
Singly Linked List
A singly linked list is a data structure that consists of a sequence of elements each of which contains a reference to the next element.
Double Ended Queue
A type of queue in which insertions and deletions can be made at both ends of the queue
1. provides easy manipulation of the pointers and the searching becomes twice as efficient. 2.Efficient utilization of memory allocation
Advantages of Circular Linked List
Recursive Call Some functionalities in browser and editor. Parsing Expression conversion
Applications of Stack
Stack Data Structure
Are linear data structures in which elements can be inserted and deleted at only one end of the list
QUEUE DATA STRUCTURE
Are linear data structures in which elements can be inserted in one end called rear and deleted from the other end called front.
Infix, Prefix or Polish, and Postfix or reverse Polish notation
Arithmetic Expression can be expressed in three notation
1. Scan the infix string from left to right one character at a time. 2. If the scanned character is an operand, append it to the postfix string. 3. If the scanned character is an operator and the stack is empty, push the operator to the stack. 4.If scanned character has higher precedence over operator on top of stack, push the operator to the stack. 5. If scanned character has lower or same precedence over operator on top of stack, pop the stack and append to postfix string. Repeat step 5b while the condition is true. 6.Repeat steps 1 to 5 until all the characters are scanned. 7.After all characters are scanned, append all remaining operators to the postfix string one at a time using pop operator. 8. Lastly, once the stack is empty, return the postfix string.
Infix to Postfix Conversion Algorithm
Output-restricted deque
Insertion can be made at both ends of the queue and deletion can be made at only one end of the queue.
Input-restricted deque
Insertions can be done only at one end of the queue and deletions can be made at both ends of the queue.
First we need to create a new node. Set the data value 80 in its data field and null in the next pointer field. Since we should not be moving the head pointer to eliminate changing the start of the list. We need to use another pointer ( current). This pointer will be used to move from one node to another. We need to set the current pointer to point initially with our first node in the list. We need to traverse until the end of the list. We will know if we are the end of the list if the pointer field pointed to by the current pointer is null. We simply set the pointer field pointed to by current to point to the new node
Operations on Singly Linked List: Inserting data on the list
1. Remove the node from the list without breaking the links created by the next pointers. 2.Deleting from the memory
Operations on Singly Linked List: Removing data on the list
We have to traverse from the start of the list using another pointer(current) and compare the data field pointed by the current pointer to the value being searched.
Operations on Singly Linked List: Retrieving data on the list
1. Check, if the next pointer field of the node is null; 2. If the next pointer field is null, then you have reached the end of the list. Otherwise, you may perform some actions with the current node. 3. Move the current pointer to the next node and do step 1.
Operations on Singly Linked List: Traversing the entire list
Once you delete the data pointed by front, you can no longer use that storage.
Problem with Simple Queue
Double Ended Queue
Provides a simple way of implementing the idea of queue
array and linked lists
Queue Data Structure can be represented as?
DEREFERENCE OPERATOR (*)
Read as "value pointed to by"
REFERENCE OPERATOR (&)
Returns the memory address of a variable.
Restricted
Specifically identifies where insertion and deletion will be performed.
Arrays and Linked Lists
Stacks can be represented in?
leaf node
The bottommost nodes in the hierarchy of a tree
Dequeue
The deletion of elements from a queue
Pop
The deletion of elements from a stack
Front
The end which the elements are deleted. (queue)
Rear
The end which the elements are inserted. (queue)
Circular Queue
The first subscript comes right after the last subscript.
Enqueue
The insertion of elements into a queue.
Push
The insertion of elements into a stack.
root node
The topmost nodes in the hierarchy of a tree
Higher priority
Which will be the first deleted a higher priority element or a lower priority element?
Array
a collection of similar data type of data items and each data item is called an element of the array
Linked List
a linear data structure which is used to maintain a list in the memory. It can be seen as the collection of nodes stored at non-contiguous memory locations. Each node of the list contains a pointer to its adjacent node.
Queue
a linear list in which elements can be inserted only at one end called rear and deleted only at the other end called front.
Stack
a linear list which insertion and deletions are allowed only at one end, called top.
circular doubly linked list
a linked list where the last element in the list is connected to the first node while the first element is connected to the last node.
circular singly linked list
a linked list where the last element in the list is connected to the first node.
front
a part of queue where elements can be deleted only at one end
rear
a part of queue where elements can be inserted only at one end
top
a part of stack where insertion and deletions are allowed only
Unordered list
a random listing of elements and operations can be performed anywhere on the list. Although, most of the time insertion happens at the end of the list.
Linear List
a type of list in which each element has a unique successor and predecessor.
Pointer
a variable that stores the memory address of another variable.
FIFO (First In First Out)
allows insertion only at the end of the list called rear, while deletion is only allowed at the beginning of the list called front.
Arithmetic Expression
an expression which involves arithmetic operators, constants and variables and ultimately evaluates to a numeric value.
Trees
are multilevel data structure with a hierarchical relationship among its elements known as nodes
Primitive Data Structure
are structures that are embedded in a particular language
Graphs
can be defined as the pictorial representation of the set of elements (represented by vertices) connected by the links known as edges
Non-Primitive Data Structures
complex data structure that is embedded in a programming language.
Pointer
contains the address of the next node in the list
Non-Linear Data Structures
data elements are not arranged in sequential structure and can have multiple successors ad predecessors.
Linear Data Structures
data elements are stored in a non-hierarchical way where each elements has successor and predecessor except the first and last element.
Ordered list
data will be inserted or remove using a key.
Operating system
decide the particular memory locations on runtime
Node
elements in a linked list.
Integer, Character, Float and Double.
examples of Primitive Data Structure
Top
holds the address of the first node of the linked list in a stack
Push(element)
insert data element at the end or top of the list.
Enqueue(element)
insert data element at the start end or rear of the list.
LIFO(Last In First Out)
only allows insertion and deletion of elements at the end of the list called top.
Pop()
remove data element at the end or top of the list.
Dequeue()
remove data element at the start or front of the list.
Top()
retrieve the data element at the end or top of the list without removing it from the stack. This will just give the data pointed by the top variable.
Rear()
retrieve the data element at the ends of the list without removing it from the queue.
Front()
retrieve the data element at the start of the list without removing it from the queue.
Top of the Stack
the end at which the elements are inserted and removed. (stack)
General list
type of list structure where we are free to add and remove data elements anywhere on the list.