Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views5 pages

Assignment 110547

Assignment

Uploaded by

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

Assignment 110547

Assignment

Uploaded by

arshsingh68623
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

B.

Tech CSE (3rd DEPARTMENT OF


Sem) COMPUTER SCIENCE
ASSIGNMENT-1 AND ENGINEERING
Data
Structures
AGCS-21302

Question Sets

Set 1: Question Number 3, 4, 11, 12, 21, 22, 32, 38, 44


Set 2: Question Number 6, 7, 14, 15, 24, 25, 33, 39, 45
Set 3: Question Number 8, 9, 19, 20, 29, 30, 35, 41, 48

Allocation of Question Sets to students

Set Uni. Roll No.


2411566,2411591,2411578,2411583,2411586,2411596,2411601,2411603,2411606,2411607,2411
1 614,2411618,2411620,2411622,2411631,2411632,2411640,2411642,2411645,2411647,2411648,2
411649,2411650,2411653,2411655,2411659,2411663,2411667,2411668,2411671

2411575,2411577,2411654,2411584,2411592,2411593,2411594,2411595,2411609,2411610,2411
2 613,2411616,2411627,2411630,2411638,2411643,2411646,2411573,2411565,2411570,2411660,2
411661,2411666,2411585,2411571,2411590,2411634,2411612,2411615,2411600,2411602,24116
64,2411604,2411636,2411639,2411588
2411576,2411581,2411599,2411608,2411611,2411625,2411626,2411629,2411633,2411637,2411
3 582,2411641,2411652,2411657,2411589,2411598,2411624,2411658,2411651,2411635

Section – A (2 Marks each)

Q.No Question CO
1 Define what a data structure is and explain its importance in computer science. CO-1
2 Discuss the difference between linear data structures and non-linear data
structures. Provide one example of each.
3 Compare and contrast two linear data structures, highlighting their strengths and
weaknesses.
4 Give a brief overview of the purpose of an arrays, describe how they store
data, and present a practical situation where using arrays is advantageous.
5 Analyze the time complexity of a given algorithm and express it using Big O
notation. If the time complexity is O(3n^2 + 5n + 2), simplify it to its most
significant term.
6 Consider the following code snippet:
void sample(int arr[], int n)
{
for (int i = 0; i < n; i++)
{
for (int j = i; j < n; j++)
{
cout << arr[i] << " " << arr[j] << endl;
}
}
}
Analyze the time complexity of the function in terms of the input size 'n'.
7 Given the functions f(n) = 2n^2 + 3n and g(n) = n^2 + 5n, determine whether
f(n) is O(g(n)), Ω(g(n)), or Θ(g(n)). Justify your answer.
8 Consider the following code snippet:
void sample(int arr[], int n)
{
for (int i = 1; i < n; i++)
{
int key = arr[i], j = i - 1;
while (j >= 0 && arr[j] > key)
{
arr[j + 1] =
arr[j]; j--;
}
arr[j + 1] = key;
}
}
Analyze the time complexity of the function in terms of the input size 'n'.
9 Suppose you have an algorithm with a time complexity of O(2^n). For an input
size of 10, calculate the number of iterations it would perform. Then, estimate
the number of iterations for an input size of 20.
10 Consider the following code snippet:
int sample(string text1, string
text2)
{
int m =
text1.length(); int n =
text2.length();
vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
if (text1[i - 1] == text2[j - 1])
dp[i][j] = dp[i - 1][j - 1] + 1;
else
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
}
}
return dp[m][n];
}
Analyze the time complexity of the function.
11 Design an algorithm to delete the element from a given location in doubly linked CO-2
list.
12 Write a function to check if a given value exists in a singly linked list.
13 Explain the advantage of using a doubly linked list over a singly linked list
with the help of example.
14 Design an algorithm to find the length of a singly linked list.
15 Write a function to delete the middle node of a singly linked list.
16 What is the time complexity of inserting a node at a given position in a doubly
linked list? Give one example.
17 Explain how you would insert a node at the end of a circular linked list.
18 Merge two sorted singly linked lists into a single sorted linked list.
19 Implement a function to detect if a singly linked list has a cycle, and if so, find
the starting node of the cycle.
20 Implement a function to reverse a singly linked list.
21 Explain the LIFO (Last-In-First-Out) property of a stack with an example. CO-3
22 How can a queue be implemented using arrays?
23 Explain the concept of a circular queue. What advantages does it offer over a
regular queue?
24 How does a stack handle function calls and returns?
25 How can a stack be used to track minimum or maximum values in constant
time?
26 Discuss the trade-offs between using an array-based queue and a linked-list-
based queue.
27 Implement a function to find the sum of all elements in a queue. Initially, the
queue contains the values [3, 7, 2, 5, 9].
28 Write a program to find the maximum element in a queue containing positive
integers. Initially, the queue contains values [12, 7, 19, 5, 15].
29. Design an algorithm to add integers from stack1 to stack2 element-wise, storing
results in stack2. Preserve extra elements in stack2. Write addStacks function.
30. Design a function to interleave the elements of two queues. For example, if
Queue A has [1, 2, 3] and Queue B has [A, B, C], the result should be [1, A, 2, B,
3, C].

Section – B (4 Marks each)


Q.No Question CO
31 What is the main difference between arrays and linked lists? Explain their CO-1
advantages and disadvantages in terms of insertion and deletion operations.
32 Discuss the significance of analyzing algorithm complexity and how it impacts
the efficiency of an algorithm. Differentiate between best-case, worst-case, and
average-case complexities, providing examples of algorithms that demonstrate
each scenario.
33 Design and implement a linear search algorithm in C++ to find the position of
the element 7 in the following array: [2, 5, 3, 7, 1, 8, 6]. Show the index where
the element is found and the total number of iterations.
34 Provide a step-by-step analysis of the time complexity of a recursive function
that calculates the Fibonacci series, and express it using Big O notation.
35 Implement the Fibonacci series calculation using both recursive and iterative
approaches. Compare the time complexities of both implementations and discuss
their respective advantages and disadvantages.
36 Explain the concept of arrays in computer science. Describe their structure, how
elements are accessed, and discuss their advantages and limitations in
programming. Provide real-world examples where arrays are commonly used.
37 Design a data structure that supports all the stack operations (push, pop, top, and CO-2
retrieving the minimum element) in constant time using linked lists.
38 You are given two linked lists. Add the two numbers and return it as a linked list.
39 Implement a function to swap two nodes in a doubly linked list without
swapping the data. Find the order of complexity.
40 Design an algorithm to determine if two singly linked lists intersect, and if they
do, find the intersection point.
41 Given a linked list, write an algorithm to remove all duplicates from the list.
Explain with the help of an example
42 Design and explain an algorithm to display employee names after deleting nodes
from single linked list where employee salary is greater than 50000 or employee
age is greater than 56. Here node consists of e_name, e_sal, e_age.
43 Explain the concept of a circular queue. What advantages does it offer over a CO-3
regular queue?
44 Given the infix expression "( a ^ b ) * ( c + d ) / e ^ ( f - g )", convert it to postfix
notation while handling exponentiation.
45 Given the infix expression "( p ^ ( q + r ) ) * s / ( t + u ) ^ ( v * w )", convert it to
postfix notation with attention to both parentheses and exponentiation.
46 Explain the concepts of stacks and queues in computer science, highlighting
their differences, core operations, and real-world applications.
47 You're given a list of integers. Implement a function to find the first non-
repeated integer in the list using a queue.
48 Create a program to help a restaurant manage its waiting list. Implement a queue
where customers can be added when they arrive and dequeued when their table
is ready.

You might also like