0% found this document useful (0 votes)
56 views

Assignment 1

The document provides instructions for Assignment-1 of the CSE1102 Data Structures course. It states that all programs must be in Java and C++ without predefined methods. Students must submit two PDF files by 05:00 PM on 20-09-2022, one for each language, containing the solutions. The solutions must be in softcopy format only. It also provides 10 questions covering topics like queues, stacks, strings, arrays, and matrices.

Uploaded by

Dhruv Khandelwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Assignment 1

The document provides instructions for Assignment-1 of the CSE1102 Data Structures course. It states that all programs must be in Java and C++ without predefined methods. Students must submit two PDF files by 05:00 PM on 20-09-2022, one for each language, containing the solutions. The solutions must be in softcopy format only. It also provides 10 questions covering topics like queues, stacks, strings, arrays, and matrices.

Uploaded by

Dhruv Khandelwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE1102 Data Structures

Assignment -1
Instructions
1. All programs should be in JAVA and C++ with no predefined Methods.
2. Upload two PDF files (one for JAVA and one for C++) of solutions in
TCS-Ion LX.
3. Deadline to submit assignment is 05:00 PM, 20-09-2022.
4. Solution should in softcopy only.

Q1. Write a recursive function that takes as input a queue and rearranges it so that it
is in reverse order. Hint: deque() the first element, recursively reverse the queue, and
the enqueuer the first element.
Q2. Write a program from scratch that reverses the words in a sentence.
Q3. Use your stack implementation to implement a queue using the Stack.
Q4. Write the function transforming a decimal number into a binary number by using
stack
Q5. Write the function that removes all even numbers from the given stack. The mutual
order of odd numbers must stay unchanged. The function returns the number of
removed numbers.
Q6. Write the function that returns duplicate stack of the given stack. Duplicate stack
contains the same elements as the original stack, and in the same order. The original
stack must stay unchanged.
Q7. For each of the use cases below pick a data structure (from the ones you have seen
in the lecture) that is best suited for that use case, and explain your choice. If you think
there is more than one suitable data structure, briefly discuss the trade-offs.

1. You want to store the stations of a public transportation line. New stations can be added
to both ends of the line, but not between existing stations. You should be able to traverse
the line in both directions.
2. You want to store a phone book, which supports looking up a phone number by name,
as well as adding and removing entries.
3. You are looking for a way out of a maze, and you are not allowed to use recursion. You
have to store the path you are currently exploring, and be able to go back one step
whenever you find yourself in a dead-end and explore a new possibility from there.

4. You want to store a sorted list of strings and support the operation of merging two
sorted lists into one, in place (without creating a copy of the lists).

5. You are writing software for a call center. When a client calls, his call should be stored
until there is a free operator to pick it up. Calls should be processed in the same order they
are received.
Q8. A palindrome is a phrase that reads the same forward and backward (examples:
‘racecar’, ‘radar’, ‘noon’, or ‘rats live on no evil star’). By extension we call every string
a palindrome that reads the same from left to right and from right to left. Develop a
recursive algorithm that takes as input a string and decides whether the string is a
palindrome. Write down your algorithm in pseudocode.
Q9. Write a program to remove the duplicate elements of a given array and return the
new length of the array.
Sample array: [20, 20, 30, 40, 50, 50, 50]
After removing the duplicate elements, the program should return 4 as the new length of
the array.
Q10. Write a program for Matrix multiplication of two matrices having different sizes?

You might also like