0% found this document useful (0 votes)
39 views12 pages

Question Bank

Uploaded by

Junaid Bhulecha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
39 views12 pages

Question Bank

Uploaded by

Junaid Bhulecha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 12
DATA STRUCTURE FACULTY OF ENGINEERING & TECHNOLOGY PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY (DIPLOMA STUDIES) COMPUTER ENGINEERING DEPARTMENT 38? SEMESTER UESTION BANK WITH SOLUTION DATA STRUCTURES 03606201 DATA STRUCTURE UNIT - 1: INTRODUCTION TO DATA STRUCTURES 1. What is Data structure?” Classification of Data Structures. What is Primitive and non-primitive data structures? Explain linear and non-linear data structures? What is an Algorithm? And its Key feature? What is Time-Complexity and Space-complexity? Define Worst-Case, Average-Case, and Best-Case Analysis? AAWELN UNIT - 2: LINEAR DATA STRUCTURE-STACK 8. What is Stack? List out the basic operations of Stack. 9. Write down the algorithm of peek(), isFull), and 10. Write down the algorithm of push() and pop(). 11. Write the application of stack. 12, Explain Infix, Prefix, and Postfix expression? 13, What is a parsing expression? -mpty(). 14, What is precedence and associativity? 15, Explain the Tower of Hanoi? 16. Explain asymptotic notation? UNIT - 3: LINEAR DATA STRUCTURE - QUEUE 17. What is Queue? 18. Explain basic operations of Queue? 19, Give the ways of implementing Queue? 20. Algorithm for Enqueue and Dequeue? 21. What is a linear Queue? Explain its limitations. 22. What is a circular queue? 23. Application of Queue? 24, Difference between a linear queue and a circular queue? UNIT — 4: LINKED LIST 25. What is Pointer? How we can use it? 26, Define Structure. 27. Explain Dynamie memory operations. 28, What is Linked list? List types of linked list. 29, Explain Insertion operation in singly linked list. 30, Explain Deletion operation of singly linked list. 31, Exaplin Circular Linked list concepts. DATA STRUCTURE UNIT - 5: SEARCHING AND SORTING 32, What is sorting and type of sorting? 33. Explain bubble sort with example and write an algorithm of bubble sort. 34, Explain selection sort with example and write an algorithm of selection sort 35, Explain quick sort with example and write an algorithm of quick sort. 36, Explain merge sort with example and write an algorithm of merge sort. 37. Explain insertion sort with example and write an algorithm of insertion sort. UNIT — 6: NON-LINEAR DATA STRUCTURES —- TREE AND GRAPH 38, What is a non-linear datastructure? 39, What is a tree? And how many types of trees? 40, What is a Binary search tree? 41, What is a tree traversal? 42, What are Inorder, Preorder, and Postorder Traversal? 43, Write down application of Binary Tree? 44, What is conversion of the general tree to binary tree?” DATA STRUCTURE CHAPTER - 1 INTRODUCTION TO DATA STRUCTURE Q-1. What is Data structure?[2 Marks] Ans:- Data Structure is a systematic way to organize Data. > It helps arrange data elements in computer memory in a way that they could be retrieved faster, easier, and more efficiently. Q-2. Classification of Data Structures? [2 Marks] a _ Ans:- eed [tae Integer Gms fied find a Goo Q-3. What are Primitive and non-primitive data structures? [3 Marks] Ans:- Primitive Data structures are Basic data structures and are directly operated by Machine instruction. © EX: Integer, Float, Character, andPointer. > Non-primitive data structures are more complicated data structures and are derived from primitive data structures. They emphasize the grouping of the same or different data items with the relationship between each item. o Ex: Amay, list, and Files. DATA STRUCTURE Q-4. Explain linear and non-linear data structures? [4 Marks] Ans:= > A data structure is said to be linear if its elements are connected in a linear fashion by means of logically or in sequence memory locations. + Ex: Stack and Queue > In Non — Linear Data Structures, the data items are not in sequence. + Ex: Tree and Graph Q-5. What is an Algorithm? And its Key feature? [2 Marks] Ans:- An Algorithm is a step-by-step procedure for solving a particular problem. Key Features: Unambiguous Input Output © Finiteness Feasibility Independent oo ° ° ° and Space-complexity? [4 Marks] Q6. What is Time-Complexi Ans:- > The Time Complexity of an algorithm represents the amount of time required by the algorithm to run to completion. The space complexity of an algorithm represents the amount of space or memory an algorithm takes in terms of the amount of input to the algorithm. Q-7. Define Worst-Case, Average-Case, and Best-Case Analysis? [3 Marks] Ans:- > Worst-Case Analysis + The maximum time required for program execution. > Average-Case Analysis * Average time required for program execution, > Best-Case Analysis ‘Minimum time required for program execution. DATA STRUCTURE CHAPTER -— 2 — LINEAR DATA STRUCTURE - STACK Q-8. What is Stack? List out the basic operations of Stack. [4 Marks] ‘Ans: Stack is an Abstract Data Type(ADT), Commonly used in most programming languages. It follows LIFO(Last In First Out), Here, the element which is placed last, is accessed first. > Basic Operations PUSH( - pushing(storing) an element on the stack. POP() — Removing(a Peek() — get the top data element of the stack, without removing it. isFull — Check if stack is full isEmpty() — Check if stack is empty. ° ° cessing) an element from the stack. Q-9. Write down the algorithm of peek(), isFull0, and isEmpty().[4 Marks] Ans: > peek() Algorithm begin procedure peck return stack[top] end procedure Implementation of peek() function in C programming language — Example int peek() { ] return stack{top]; } J > istull Algorithm begin procedure isfull if top equals to MAXSIZE return true else return false | DATA STRUCTURE endif end procedure Implementation of isfull() funetion in C programming language — Example bool isfull() { ifitoy MAXSIZE) return true; else return false; > isempty() Algorithm begin procedure isempty if top less than 1 return true else return false endif end procedure Implementation of isempty() function in C programming language is slightly different. We initialize top at -1, as the index in array starts from 0. So we check if the top is below zero or -1 to determine if the stack is empty. Here's the code — Example bool isempty() { iftop = -1) return true; else return false; Q-10. Write down the algorithm of push() and pop()[4 Marks] Ans: > push, begin procedure push: stack, data if stack is full return null endif DATA STRUCTURE top —top +1 stack{top] — data end procedure > _popd) begin procedure pop: stack | if stack is empty return null endif data < stack{top] top —top-1 return da end procedure Q-I1. Write the application of stack. [2 Marks] Ans:- > tower of Hanoi implement > Expression conversion(Infix to Postfix, Postfix to Prefix, ete.) > Parsing > The simplest application of a stack is to reverse a word. Q12. Explain Infix, Prefix, and Postfix expression? [3 Marks] > Infix © We write the expression in infix notation, e.g. arbre, where operators are used in-between operands. > Prefix © In this expression, the operator is prefixed to operands, i.e., the operator is written ahead of operands. For example, tab. This is equivalent to a+b infix notation. > Postfix © In this, the operator is post fixed to the operands ie. the operator is written after the operands. For example, abt. This is equivalent to a+b infix notation DATA STRUCTURE Q-13. What is a parsing expression? [2 Marks] Ans:- As we have discussed, itis not a very efficient way to design an algorithm or program ‘o parse infix notations. Instead, these infix notations are first converted into either postfix or prefix notations and then Computed. To parse any arithmetic expression, we need to take care of operator precedence and associativity also. Q-14, What is precedence and associativity? [2 Marks] Ans:- Operator precedence: It dictates the order of evaluation of operators in an expression. Associativity: It defines the order in which operators of the same precedence are evaluated in an expression, Explain the Tower of Hanoi? [4 Marks] ‘Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. Each move consists of taking the upper disk from one of the stack sand placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack. No disk may be placed on top of a smaller disk. cy ' 2 ‘ & = a 4 a ° a @ © . ‘ 7 ‘oa ¢ 5 3 e a 8 © Q.16. Explain asymptotic notation? [2 Marks] Ans:~ Asymptotic Notations are the expressions that are used to represent the complexity of an algorithm, Ex:- Worst-Case, Average- DATA STRUCTURE CHAPTER ~ 3 LINEAR DATA STRUCTURE - QUEUE Q-17. What is Queue? [2 Marks} Ans:- Queue is an Abstract Data Structure similar to Stack. The queue is open at both ends. One end is always used to insert data and another end is always used to remove data. It follows FIFO(First In First Out). Q-18. Explain basic operations of Queue. [4 Marks] Ans > Basic Operations © Enqueue() — add(store) items in the queue. © Dequeue() ~ remove(access) an item from the queue.. © Peek() — gets the element at the front of the queue without © removing it. © Isfull) — checks if the queue is ull © Isempty() — checks if the queue isempty. Q-19. Give the ways of implementing Queue? [2 Marks] Ans: > Sequential allocation: The sequential allocation in a Queue can be implemented using an array. > Linked list allocation: The linked list allocation in a Queue can be implemented using a linked list. Q-18. Algorithm for Enqueue and Dequeue? [3 Marks] Ans:- > Enqueue procedure enqueue(data) if queue is full return overflow Endif rear — rear + 1 queue{rear] — data return true end procedure 40 DATA STRUCTURE > Dequene © procedure dequeue if queue is empty return underflow end if, data = queue[front] front — front + 1 return true end procedure Q19. What is a linear Queue? Explain i limitations. [3 Marks] ‘Ans:- A linear queue is a linear data structure that serves the request first, which has been arrived first. It consists of data elements that are connected in a linear fashion. It has two pointers, ie. front and rear, where the insertion takes place from the front end, and deletion oceurs from the front end Ina linear queue, the traversal through the queue is possible only once ,ie., once an element is deleted, we cannot insert another clement in its position. This disadvantage of a linear queue is overcome by a circular queue, thus saving memory. Q-20. What is a circular queue? [3 Marks} Ans:- Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle, It is also called 'Ring Buffer’. In a normal Queue, we can insert elements until the queue becomes full A circular Queue is also a linear data structure, which follows the principle of FIFO (First In First Out), but instead of ending the queue at the last position, it again starts from the first position after the last, hence making the queue behaves like a circular data structure. Q23:- Application of Queue? [2 Marks] Ans:= 1) When are source is shared among multiple consumers. Examples include CPU scheduling, Disk Scheduling. 2) When data is transferred asynchronously (data not necessarily received at the same rateassent)between two processes. Examples include JOBuflers, pipes, file 10, ete 3) In Operating systems: a) Semaphores 44 DATA STRUCTURE b) FCFS ( first come first serve) scheduling, for example, FIFO queue €) Spooling in printers d) Buffer for devices like keyboard 4) In Networks: a) Queues in routers/swit hes Mail Queues = Difference between a linear queue and a circular queue? [3/4 Marks] Ans: Key Points Linear Queue Circular Queue Basic Organizes data elements and| Arranges data in a circulay instructions in a sequential ordey] pattern where the last element one after the other, is connected with the firs element. Order of task) FIFO(First-In-First-Out) The order of task execution execution may change. Insertion and The new element is added from] Insertion and deletion cai deletion the rear end and removed from] be done at anyplace, the front, performance inefficient Works better than linea queue. ‘Memory Requires more memory. Requires less memory. requirement 49

You might also like