Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
37 views
10 pages
DS
Math discret
Uploaded by
alainfabo21
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
Download now
Download
Save DS For Later
Download
Save
Save DS For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
37 views
10 pages
DS
Math discret
Uploaded by
alainfabo21
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
Download now
Download
Save DS For Later
Carousel Previous
Carousel Next
Download
Save
Save DS For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 10
Search
Fullscreen
Roll No. Pandit Deendayal Energy University Mid Semester Examination: September 2023 B. Tech. (Computer Science and Engineering) ‘Semester - Date: 12/09/2023 Course Name: Data Structures Time: 2 hours Course Code: 20CP201T. Max. Marks: 50 Instructions: 1. Do not write anything other than your roll number on question paper. 2. Read question paper properly and assume suitable data wherever essential by mentioning it clearly. 3. Write appropriate units, nomenclature, and draw neat diagrams wherever required. Que. Description co No. Marks | Mapping (Ql | Select the correct option (I Marks) and give proper justification (2 Marks) for each of the following Multiple-Choice Questions. QUAY | Analgorithm A reads 500 integers. These integers ae values in the range [0, 100] that represent the scores of 500 students. It then prints the frequency of each score above 50, What would be the best way for A to store the frequencies? i. Amay of 50 numbers ii, Array of 100 numbers iii, Array of 500 numbers iv. Dynamically allocated array of 550 numbers DUG [A queue is implemented wsing a cireular Tinka list, that i, the Tok part of rear node contains the address of front node of the lst. There is a restretion that we can only use one pointer to access the elements ofthe queve. Let this pointer be ‘per’ To which node “ptr” shold point such that both enQueneQ) and deQueuie() are performed in constant time? i. Front Node ji, Rear Node Node next to Front iv.__Not Possible with single pointer GH] [A aueue is implemented using a non-ciroular singly linked list I has a head pointer pointing tothe first node ofthe list and a tail pointer pointing tothe last node of thelist. Let 'n’ denotes the number of nodes in the queue. Let enquewe() be implemented by inserting a new node at the head, and dequeweQ be implemented by deletion of a node from the tail. Which one of the following is} 3 | CO-3 the time compiexties of the time-efficient implementation of enquewe() and | dequewe() respectively, for this data structure? 0,001) i, 00,0) O(n), 001) iv. __0(m),0(n) Qi (D) | Assume that the § elements (1,2,4,5,9) are pushed and popped using some possible combinations of 5 rusi() and 5 popO operations. The elements should be compulsorily pushed inthe sequence 2, 5, 1,9, 4. However, they ean be popped con 3 co2 any time in between, Which of the following output permutation can’tbe obtained | 3 cos in the same order as below? i 1,5,9,2,4 i Bee 51 94 ii, __2,9,1,4,5 iv. 5.1,4,2,9 Page 1 of 2@ Fill in the blanks with correct answers (I Marks) and give proper reason to your answer (2 Marks) for each of the following. QA) ‘One aspect of linear data structures that makes it different from the non Tinear data structures is cO-1 ee ‘Consider the two stacks 5; and 5;, Various operations are performed on these stacks in the following given order: push(S,.54), push(S,,52), push(S;.22), Push(Se,55), push(S;,52), q = pop(S,). push(S,,35), p= pop(S,), Push(Sy,10), push(Sa,15), pusk(Sy.20), q = poplSi) p= portSi). push(Sy,20). q = pop(Sa). Here, push(S, a) insert the element a into stack S ‘whereas pop(S) returns the deleted clement from stack S. After all these operations, the value of p + g is —--- co2 QO Postfix equivalent of the infix expression 3 = log(x + 1) — log (@/2) is ——- Cd eo The following postfix expression with single digit operands is evaluated using stack: 823/23 « +51 + —. After the first « (multiplication) is evaluated, the top two elements of the stack are ~~-e-(top) and w-----~---(next 10 top). co-4 QA) Write any 5 differences between linear and non-linear data structures, COT Q3(B) What is the output of the following function, where “start” points to the first node of the linked ist 1+ 2 3+ 4+ 5+ 6? void fun(struct node » start) if(start return; printf((%d", start — data); NULL) if(start + next # NULL) fun(start + next > next); printf((%d", start + data); 3 ‘Also, explain in detail how your output is obtained, coz @ Write algorithms to implement following operations of the circular queue using an array: 1. enQueue(): to insert an element in the circular queue. 2._deQueue(); to delete an element from the circular queue, ‘OR ‘Write algorithms to implement following operations of the stack using an array: 1. push():10 insert an element in the stack. 2._pop():to delete an element from the stack. cos A) ‘Apply infix to postiix algorithm that uses stack to convert the following infix expression into its corresponding postfix notation. A+ (B+C=D'G)—H) co-4 eB) ‘Write pseudocode to evaluate the postfix expression using suitable data structures. co-4 ———— == End of the Question Paper Page 2 of 2Powered by AI Copilot Sure, here are the solutions to the questions in your mid-semester exam paper: Qu. (A) Best way to store frequenci + ii, Array of 100 numbers + Justification: Since the scores range from 0 to 100, an array of 100 elements is su frequency of each score. QI. (B) Pointer for constant time enQueue() and deQueue(): + ii, Rear Node + Justification: Pointing to the rear node allows both enQueue() and deQueue() operations to be performed in constant time. Qo Time complexities of enqueue() and dequeue(): * if. (OC), (OM) «Justification: Inserting at the head is (O(1)), but deleting from the tail requires traversing the list, making it (O(n)), Ql. (D) Output permutation that can’t be obtained: * iv.5,1,4,2,9 tification: This sequence violates th Q2. (A) Value of p+ q: tack’s LIFO (Last In, Fi + Answer: 67 + Justification: After performing the given operations, p = 55 and q = 12, so p+ q= 67. Q2. (B) Aspect of linear data structures: + Answer: Elements are arranged sequentially. + Justification: Linear data structures have elements in a sequence, unlike non-linear s ructures. Q2.0 Postfix equivalent of the infix expression: + Answer: (3 \log(x + 1) - og(a/2)) + Justification: Convert the infix expression to postfix notation. Q2. (D)Top two elements of the stack after first multiplication: + Answer: 8 and 2 + Justification: Evaluate the postfix expression step by step. Q3. (A) Differences between linear and non- jinear data structures: 1, Arrangement: Linear structures are sequential; non-linear are hierarchical. 2. Traversal: Linear structures are traversed linearly; non-linear require specific traversal methods. 3, Examples: Arrays and linked lists are linear; trees and graphs are non-linear. 4. Memory Utilization: Linear structures use contiguous memory; non-linear may use non-contiguous memory. 5. Complexity: Operations in linear structures are generally simpler than in non-linear structures. Q3.(B) Output of the function: + Answer: 135531 + Justification: The function prints nodes in a specific order based on the given conditions. Q4 Algorithms for circular queue operations: 1, enQueueQ): void enQueue(int value) { if ((rear + 1) % SIZE == front) { 7/ Queue is full y else { rear = (rear + 1) % SIZE; queue[rear] = value; } 2. deQueue(): int dequeue() { if (Front == rear) { 17 Queue is enpty return 13 } else { front = (front + 1) % SIZE; return queue[front]5 } Q5. (A) Pseudocode to evaluate postfix expression: 1. Initialize an empty stack. 2. For each token in the postfix expression: © If the token is an operand, push it onto the stack. © Ifthe token is an operator, pop the required number of operands from the stack, perform the ‘operation, and push the result back onto the stack. 3. The result will be the only element left in the stack. Q5. (B) Infix to postfix conver:* Given infix expression: (A + (B * C - D“G)- H) + Postfix expression: (ABC*DG”-H-) Feel free to ask if you need further clarification on any of these solutions!Roll No. Deendayal Energy University Mid Semester Examination - September 2022 B.Tech. (Computer Science and Engineering) Date: 23/09/2022 Course Name: Data Structure ime: 2 hours Course Code: 20CP201T Instructions: 1. Do not write anything o :0u roll number on question paper 2. Assume suitable data whe: and mention it clearly, 3._ Write appropriate units, 1: , and draw neat diagrams wherever require. uestion | Description ; 5 le No. : Marks, Q1-(A)_ Which one ofthe following isthe dlsadvantage oF arays? —— {- Data structure like queue or stack eannot be implemented {i There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size, | ii, Easier to store elements of same datatype. | iv. _Elements are sequentially accessed. QI-(B) | What does “stack underflow” refers to? i, Accessing item from an undefined stack, Adding items to a stack that is already full, ii. Removing items from an empty stack. iv.__Index out of bounds exception. ‘What the time complexity of pop) operation when the stack is implemented using an array? & 0a) i. om O(ogn) iv. O(log) ‘What is the need for a circular queue? cffective usage of memory ji, easier computations to delete elements based on priority iv. _ implement FIFO principle in queues jh. circular queue; how do you inerement the rear end of the queue? Here, REAR points to the last element of circular queue and CAPACITY is the size of the queue, i, REAR=REAR +1 REAR = (REAR + 1) % CAPACITY REAR (REAR % CAPACITY) + | REAR= REAR - 1 Q2.(A) ferentiate between the linear and non-linear data structures, Q2.(B) | Write an algorithm or pseudocode to evaluate the postfix expression using *_| suitable data structure, ENS} how Priority Queue can be applied, with an appropriate example. fix to postfix algorithm that uses stack to convert the following infix expression into its corresponding postfix notation. A+B+(C~D)/E+F~G, Q3.(B)Powered by AT Copilot Sure, I can help with that! Here are the solutions to the questions in your mid-semester exam paper: Qu.(A) Disadvantage of array: ‘+ iii, There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size. Qi. B) Stack underflow refers te + iii, Removing items from an empty stack, Qo Time complexity of pop() operation in an array-implemented stack: * i.(O(1)) Ql.) Need for a circular queue: + i, Effective usage of memory QI. (E) Incrementing the rear end of a circular queue: * ii, (Wext{REAR} = (\text{REAR} + 1) % \text{CAPACITY} ) Q2. (A) Difference between linear and non-linear data structures: + Linear Data Struetures: Elements are arranged sequentially (e.g., arrays, linked lists). + Non-linear Data Structures: Elements are arranged hierarchically (c.g., trees, graphs). Q2. (B) Algorithm to evaluate postfix expression: I. Initialize an empty stack. 2. For each token in the postfix expression: © If the token is an operand, push it onto the stack: © Ifthe token is an operator, pop the required number of operands from the stack, perform the operation, and push the result back onto the stack. 3. The result will be the only element left in the stack. Q3.(A) Priority Queue Application Example:+ Example: Task scheduling in operating systems where tasks with higher priority are processed first. Q3. (B) Infix to postfix conversion: + Given infix expression: (A+B +(C -D)/E+F-G) + Postfix expression: ( AB+CD-E/+F+G- ) Q4 Operations on stack ‘S’ and queue ‘Q push(A) -> S: [A], Q:[] push(B) > S:[A, B], Q: [] pop() > S: [A], Q: [C}, Output: B enqueue(D) > 8: [A], Q: [C, D] is : dequeue() > S: (A, EJ. Q: [D], Output: C push(F) > S: (A, B, F],Q: [D] enqueue(G) -> 10, dequeued) . F], Q: [G], Output: D 11, push(H) -> S: [A, E, FH], Q: [G] 12, dequeue() > S: [A, E, F, H}, Q: [], Output: G 13. push(I) -> S: [ 14, dequeue() > S: 15, dequeue() > S: 16, push(J) > S: 17. pop() > S: [A, 18, enqueue(K) > S: 19, push(L) -> S: [A. 20. pop() > 8: [A, 21. dequeue() > S. 22, enqueue(M) 23. enqueue(N) -> 24, enqueue(O) 25. pop() > S: [A, 26, dequeue) > S Q5. (A) Operation performed by function(Q): SRA aVaYNe 1.0 f : [K], Output: L Qf], Output: K ', H, 1], Q: [M] Ere + The function reverses the elements of the queue. Q5. (B) Time complexity of the given program: + The time complexity is (O(n2)). Q5.0 Time complexity of the given program: ‘+ The time complexity is (O(log \log n)).Feel free to ask if you need further clarification on any of these solutions!
You might also like
DS Utech Final May2022
PDF
No ratings yet
DS Utech Final May2022
7 pages
Data Structure and Algorithms
PDF
67% (3)
Data Structure and Algorithms
5 pages
Multile Choice Questions - Unit - 3
PDF
No ratings yet
Multile Choice Questions - Unit - 3
8 pages
Unit Iii Linear Data Structures: Syllabus
PDF
No ratings yet
Unit Iii Linear Data Structures: Syllabus
19 pages
10050301 DS QuestionBank
PDF
No ratings yet
10050301 DS QuestionBank
9 pages
GATE Questions On DSA
PDF
No ratings yet
GATE Questions On DSA
13 pages
DS Unit 1 and II Q Bank
PDF
No ratings yet
DS Unit 1 and II Q Bank
6 pages
MCQ - FILL in The Balnks
PDF
No ratings yet
MCQ - FILL in The Balnks
6 pages
CUET Mock4 (DS + InC + OS) - Random - Ans
PDF
No ratings yet
CUET Mock4 (DS + InC + OS) - Random - Ans
10 pages
stack and queue
PDF
No ratings yet
stack and queue
6 pages
MCQ STACK Queue
PDF
No ratings yet
MCQ STACK Queue
4 pages
Data Structures and Algorithms Question Bank-1
PDF
No ratings yet
Data Structures and Algorithms Question Bank-1
16 pages
Paper G Data Structure 23-12-24
PDF
No ratings yet
Paper G Data Structure 23-12-24
2 pages
PART-A (Each 1 Mark) 20 Marks
PDF
100% (1)
PART-A (Each 1 Mark) 20 Marks
3 pages
Unit D
PDF
No ratings yet
Unit D
7 pages
Data Structure... 1 To 5 Units
PDF
No ratings yet
Data Structure... 1 To 5 Units
125 pages
DS -CHAPTER WISE MCQ WITH SOLVE-2024
PDF
No ratings yet
DS -CHAPTER WISE MCQ WITH SOLVE-2024
12 pages
DataStructures_with_CO-Level_2023(1).docx
PDF
No ratings yet
DataStructures_with_CO-Level_2023(1).docx
2 pages
Exe DS
PDF
No ratings yet
Exe DS
3 pages
CUET Mock3 (DS + InC + OS) - Random - Ans
PDF
No ratings yet
CUET Mock3 (DS + InC + OS) - Random - Ans
10 pages
19-series (1)
PDF
No ratings yet
19-series (1)
8 pages
dsa-old-question-collection
PDF
No ratings yet
dsa-old-question-collection
31 pages
Stacks Queues Unit II MCQs With Options
PDF
No ratings yet
Stacks Queues Unit II MCQs With Options
11 pages
Bank of Questions Data Structures_EyadReda
PDF
No ratings yet
Bank of Questions Data Structures_EyadReda
10 pages
BCA-II_CN121 Introduction to Data Structures_Theory Tutorial
PDF
No ratings yet
BCA-II_CN121 Introduction to Data Structures_Theory Tutorial
6 pages
DataStrustures MCQ Sample With Answerkey
PDF
No ratings yet
DataStrustures MCQ Sample With Answerkey
13 pages
CUET Mock4 (DS + InC + OS) - Random
PDF
No ratings yet
CUET Mock4 (DS + InC + OS) - Random
8 pages
II CSE DS I-MID Objective (1)
PDF
No ratings yet
II CSE DS I-MID Objective (1)
5 pages
1221 Question Paper
PDF
No ratings yet
1221 Question Paper
2 pages
6 Data structures in python lesson 6
PDF
No ratings yet
6 Data structures in python lesson 6
6 pages
Atul Parashar DS Paper
PDF
No ratings yet
Atul Parashar DS Paper
10 pages
c1_merged
PDF
No ratings yet
c1_merged
78 pages
CS2201 Data Structure Tutorial
PDF
No ratings yet
CS2201 Data Structure Tutorial
6 pages
Unit 2 MCQ
PDF
100% (1)
Unit 2 MCQ
14 pages
DSD-Question Bank
PDF
No ratings yet
DSD-Question Bank
22 pages
Btech Data Structures
PDF
No ratings yet
Btech Data Structures
15 pages
CS 8391 - Data Structures
PDF
No ratings yet
CS 8391 - Data Structures
4 pages
Tausif Nawaz CS251 Assignment 1
PDF
No ratings yet
Tausif Nawaz CS251 Assignment 1
9 pages
DS ANSWER KEY CIA I
PDF
No ratings yet
DS ANSWER KEY CIA I
2 pages
Data Structures Midterm Exam Model Answer
PDF
No ratings yet
Data Structures Midterm Exam Model Answer
7 pages
Data Structures 2022
PDF
No ratings yet
Data Structures 2022
3 pages
Hllo
PDF
No ratings yet
Hllo
12 pages
Dsa Module01 Module02 Questions Updated
PDF
No ratings yet
Dsa Module01 Module02 Questions Updated
2 pages
CA-II DS Question Bank
PDF
No ratings yet
CA-II DS Question Bank
6 pages
Assignment 02 FA20
PDF
No ratings yet
Assignment 02 FA20
2 pages
Question Bank Unit-2
PDF
No ratings yet
Question Bank Unit-2
3 pages
Stack Queue
PDF
No ratings yet
Stack Queue
7 pages
DS Chapter 1 and 2 Notes
PDF
No ratings yet
DS Chapter 1 and 2 Notes
10 pages
Fds1 Merged
PDF
No ratings yet
Fds1 Merged
15 pages
Numeric Infosystem Pvt. LTD: Section - A 1 Marks Questions (Questions 1 To 141) (PAGE 1 TO 14)
PDF
No ratings yet
Numeric Infosystem Pvt. LTD: Section - A 1 Marks Questions (Questions 1 To 141) (PAGE 1 TO 14)
14 pages
Lab-05 - Linear and Circular Queue
PDF
No ratings yet
Lab-05 - Linear and Circular Queue
5 pages
SE ZG519 EC-2R SECOND SEM 2023-2024
PDF
No ratings yet
SE ZG519 EC-2R SECOND SEM 2023-2024
5 pages
CS2005_merged
PDF
No ratings yet
CS2005_merged
15 pages
CUET Mock3 (DS + InC + OS) - Random
PDF
No ratings yet
CUET Mock3 (DS + InC + OS) - Random
8 pages
Data Structure Unit-2 Quiz
PDF
No ratings yet
Data Structure Unit-2 Quiz
7 pages
DS2022
PDF
100% (1)
DS2022
5 pages
23A05201T Data Structures
PDF
No ratings yet
23A05201T Data Structures
2 pages
Data Structure
PDF
No ratings yet
Data Structure
37 pages