Data Structures

Arrays - ds easy problem solving (basic) max score: 10 success rate: 93.21%, 2d array - ds easy problem solving (basic) max score: 15 success rate: 93.16%, dynamic array easy problem solving (basic) max score: 15 success rate: 86.81%, left rotation easy problem solving (basic) max score: 20 success rate: 91.28%, sparse arrays medium problem solving (basic) max score: 25 success rate: 97.29%, array manipulation hard problem solving (intermediate) max score: 60 success rate: 61.28%, print the elements of a linked list easy problem solving (basic) max score: 5 success rate: 97.16%, insert a node at the tail of a linked list easy problem solving (intermediate) max score: 5 success rate: 95.25%, insert a node at the head of a linked list easy problem solving (basic) max score: 5 success rate: 98.32%, insert a node at a specific position in a linked list easy problem solving (intermediate) max score: 5 success rate: 96.97%, cookie support is required to access hackerrank.

Seems like cookies are disabled on this browser, please enable them to open this website

600.226: Data Structures (Spring 2017)

Assignment 4: stacking queues.

  • Out on: February 23, 2017
  • Due by: Thursday , March 2 before 10:00 pm
  • Collaboration: None
  • Grading: Packaging 10%, Style 10% (where applicable), Testing 10% (where applicable), Performance 10% (where applicable), Functionality 60% (where applicable)

The fourth assignment is mostly about stacks and queues. For the former you’ll build a simple calculator application, for the latter you’ll implement the data structure in a way that satisfies certain performance characteristics (in addition to the usual correctness properties).

Problem 1: Calculating Stacks (50%)

Your first task is to implement a basic RPN calculator that supports integer operands like 1 , 64738 , and -42 as well as the (binary) integer operators + , - , * , / , and % . The style of arithmetic expressions our calculator will evaluate is also called a post-fix notation. Stacks are great for doing this job! Your task is to write a driver (client) program that uses our Stack interface and one of the given implementations to perform these calculations as specified here.

Your program should be called Calc and work as follows:

  • The user enters input through System.in consisting of operands and operators, presumably in post-fix notation. We have also included some extra operators to get information about results and the current state of the stack.
  • If the user enters a valid integer, you push that integer onto the stack.
  • If the user enters a valid operator, you pop two integers off the stack, perform the requested operation, and push the result back onto the stack.
  • If the user enters the symbol ? (that’s a question mark), you print the current state of the stack using its toString method followed by a new line.
  • If the user enters the symbol ^ (that’s a caret), you pop the top element off the stack and print only that element (not the entire stack) followed by a new line.
  • If the user enters the symbol ! (that’s an exclamation mark or bang), you exit the program.

Note that there are a number of error conditions that your program must deal with gracefully for full credit. We’ll give you two examples for free, you’ll have to figure out any further error conditions for yourself:

  • If the user enters blah or 1.5 or anything else that doesn’t make sense for an integer calculator as specified above, your program should make it clear that it can’t do anything helpful with that input; but it should not stop at that point.
  • If the user requests an operation for which there are not enough operands on the stack, your program should notify the user of the problem but leave the stack unchanged; again, it should certainly not stop at that point.

Of course this means that you’ll have to print error messages to the user. Error messages must be printed to standard error and not to standard output! (Of course, the regular input and output is done through standard input and standard output as usual.) Furthermore, all error messages must start with the symbol # (that’s a hash sign) and be followed by a new line!

Here are two examples for interacting with Calc that will hopefully help you understand what you’re trying to achieve. First a “slow” example:

Here $ is the shell prompt. After starting the program, the first command was ? to print the stack (which is empty at this point, hence [] is the output). Then the user typed 10 followed by ? and we see that the stack now holds that number: [10] . Now the user typed two numbers 20 30 in sequence before hitting return. When we check the stack now using ? we get the answer [30, 20, 10] so obviously the “top” of the stack is to the left. Then we see the * operator being typed, which will multiply the top two numbers. We use ? again to check the result: [600, 10] . This is followed by the + operator, which will add the top two numbers. Again we check with ? and get [610] as we’d expect. The ^ command prints the same result 610 and pops if off the stack. So the next ? shows an empty stack again. Finally the user typed the ! command to quit, returning us to the shell. Here’s the same example, done “fast” this time:

As you can see, if the entire sequence of integers, operators, and commands is entered on a single line, they are all executed in order. It’s like having our own little programming language! Finally, here’s an example for the sample error conditions described above:

Note in particular that blah and 1.0 lead to error messages but are otherwise ignored (the program doesn’t stop); same for the two + operations when the stack only has a single element (the program doesn’t even modify the stack in that case).

Implementation Details and Hints

  • You must create an empty Stack to hold intermediate results and then repeatedly accept input from the user. It doesn’t matter whether you use the ArrayStack or the ListStack we provide, what does matter is that the specific type only appears once in your program. (In other words, the type of the stack reference variable you use in your program must be Stack and not ArrayStack or ListStack . Polymorphism!)
  • Note that we’re dealing with integers only (type Integer in Java) so / stands for integer division and % stands for integer remainder . Both of these should behave in Calc just like they do in Java. The details are messy but worth knowing about, especially regarding modulus .
  • You may find it interesting to read up on Autoboxing and Unboxing in Java. It’s the reason we can use our generic Stack implementations for Integer objects yet still do arithmetic like we would on regular int variables.
  • Only if you’re not afraid of learning on your own: You’ll be able to use the matches method of the String class to your advantage when it comes to checking whether a valid operator was entered. (But you can just as well do it with a bunch of separate comparisons or a simple String variable containing all the valid operation symbols if you don’t want to learn about regular expressions .)

Problem 2: Hacking Growable Deques (50%)

Your second task is to implement a generic ArrayDeque class as outlined in lecture. As is to be expected, ArrayDeque must implement the Deque interface we provided on Piazza .

Your implementation must be done in terms of an array that grows by doubling as needed. It’s up to you whether you want to use a built-in Java array or the SimpleArray class you know and love; just in case you prefer the latter, we’ve once again included it on the Piazza post for this assignment. Your initial array must have a length of one slot only! (Trust us, that’s going to make debugging the “doubling” part a lot easier.)

Your implemention must support all Deque operations except insertion in (worst-case) constant time ; insertion can take longer when you need to grow the array, but overall all insertion operations must be constant amortized time as discussed in lecture.

You should provide a toString method in addition to the methods required by the Deque interface. The toString will orient the front of the deque at the left and the back at the right. For example, a new dequeue into which 1, 2, and 3 were inserted using insertBack() should print as [1, 2, 3] whereas an empty dequeue should print as [] .

You must write JUnit 4 test drivers for the Deque interface and your ArrayDeque class. All the general test cases should go into DequeTestBase.java whereas test cases specific to ArrayDeque (if any!) should go into ArrayDequeTest.java . (Follow the example for testing the Array interface and its various implementations we posted on Piazza and discussed in lecture.)

Be sure to test all methods and all exceptions as well. Note that it is not enough to have just one test case for each method; there are plenty of complex interactions between the methods that need to be covered as well. (And yes, of course you need to test toString !)

Documentation

Don’t forget to add proper javadoc comments for your ArrayDeque class. Running checkstyle will remind you to do this!

General Assignment Hints

  • Ensure that the version of your code you hand in does not produce any extraneous debugging output anymore!
  • Pay attention to edge cases in the input your classes and programs are expected to handle! For example, make sure that you handle the empty input in a reasonable way for Problem 1.
  • Private helper methods are your friends. Your best friends, actually! If you don’t write plenty of them, you’ll have a much harder time getting your code to work.

Bonus Problem (0%)

Develop an algebraic specification for the abstract data type Queue . Use new , empty , enqueue , dequeue , and front (with the meaning of each as discussed in lecture) as your set of operations. Consider unbounded queues only, unless of course you want to do a bonus bonus problem on bounded queues as well.

The difficulty is going to be modelling the FIFO (first-in-first-out) behavior accurately. You’ll probably need at least one axiom with a case distinction using an if expression; the syntax for this in the Array specification for example.

Doing this problem without resorting to Google may be rather helpful for the upcoming midterm. There’s no need to submit the problem, but of course you can submit it if you wish; just include it at the end of your README file.

Deliverables

You must turn in a zipped ( .zip only) archive containing all source code, your README file, and any other deliverables required by the assignment. The filename should be HW##-jhed.zip with ## replaced by the 2-digit number (use leading 0s) of this assignment (see above) and jhed replaced by your Blackboard login. (For example, Peter would use HW03-pfroehl1.zip for his submission of Assignment 3.) The zip should contain no derived files whatsoever (i.e. no .class files, no .html files, etc.), but should allow building all derived files. Include a plain text README file (not README.txt or README.docx or whatnot) that briefly explains what your programs do and contains any other notes you want us to check out before grading. Your answers to written problems should be in this README file as well. Finally, make sure to include your name and email address in every file you turn in (well, in every file for which it makes sense to do so anyway)!

For reference, here is a short explanation of the grading criteria; some of the criteria don't apply to all problems, and not all of the criteria are used on all assignments.

Packaging refers to the proper organization of the stuff you hand in, following both the guidelines for Deliverables above as well as the general submission instructions for assignments.

Style refers to Java programming style, including things like consistent indentation, appropriate identifier names, useful comments, suitable javadoc documentation, etc. Many aspects of this are enforced automatically by Checkstyle when run with the configuration file available on Piazza . Style also includes proper modularization of your code (into interfaces, classes, methods, using public , protected , and private appropriately, etc.). Simple, clean, readable code is what you should be aiming for.

Testing refers to proper unit tests for all of the data structure classes you developed for this assignment, using the JUnit 4 framework as introduced in lecture. Make sure you test all (implied) axioms that you can think of and all exception conditions that are relevant.

Performance refers to how fast/with how little memory your program can produce the required results compared to other submissions.

Functionality refers to your programs being able to do what they should according to the specification given above; if the specification is ambiguous and you had to make a certain choice, defend that choice in your README file.

If your programs cannot be built you will get no points whatsoever. If your programs cannot be built without warnings using javac -Xlint:all we will take off 10% (except if you document a very good reason; no, you cannot use the @SuppressWarnings annotation either). If your programs fail miserably even once, i.e. terminate with an exception of any kind, we will take off 10% (however we'll also take those 10% off if you're trying to be "excessively smart" by wrapping your whole program into a universal try-catch).

Browse Course Material

Course info.

  • Prof. Erik Demaine

Departments

  • Electrical Engineering and Computer Science

As Taught In

  • Algorithms and Data Structures

Learning Resource Types

Advanced data structures, assignments.

  • There will be a weekly one-page assignment, 10 assignments in total.
  • You may skip any one problem, or we will ignore the problem with the lowest grade. If you volunteered to scribe twice, we will ignore the lowest two grades.
  • The answers must be typeset in LaTeX. The answers must fit in one page, or your solution will not be read. Use at least 10 pt font and 1 inch margins. This rule is meant to prepare you for writing research publications: one often has to explain great ideas in a very limited number of pages.
  • Submissions must be made online and consist of a compiled PDF document.
  • Grades and comments will be posted online.
  • Solutions do not need to include all calculations, trivial details etc. Just prove to us that you found the solution, and you understand it well.
  • 0 = You didn’t get it. Filling one page to the brim does not mean you can’t get zero. Please don’t write stuff you know is wrong.
  • 1 = Your solution was ultimately a good one, but the write-up contained significant errors or omissions.
  • 2 = (We think) you got it.

facebook

You are leaving MIT OpenCourseWare

Data Structures Assignment 1

(implementing a queue using stacks), due: aug 17.

This assignment is for you to get comfortable with JAVA features. You will get a chance to use class hierarchy, File I/O, Exception handling, Thread programming, Inter-thread synchronization etc. Please read the entire assignment carefully, many times over.

The goal is to implement a data structure called “queue” using another data structure called “stack”. Refer chapter 4 of the Goodrich and Tamassia book for stacks and queues.

Programming problem 1 : Implement a stack using an array. Implement the stack interface defined here . Use generics in Java to make sure that you can use the stack for any type of data. You may assume that the number of elements inserted into the stack never exceeds 100,000. Do NOT use the inbuilt Stack class of java. Name your stack implementation as myStack .

Queue using two Stacks

The goal of this assignment is to implement a queue using two stacks. We will employ two different ideas for this and try to understand why one idea is better than the other. Let us first consider a naive implementation.

Implementation 1:

Let S1 and S2 be the two stacks to be used in the implementation of our queue. All we have to do is to define the enqueue and dequeue operations for the queue.

enqueue ( T a)

            S1.push( a);

dequeue ( ){

            if (S1 is empty) return(error);

            while( S1 is not empty){

                        S2.push( S1.pop());

            }

            r <- S2.pop( );

            while( S2 is not empty){

                        S1.push( S2.pop());

return( r);

Programming Problem 2 : Use your stack implementation (programming problem 1) to implement a queue using the above pseudocode . Implement the queue interface defined here . Name your implementation myQueue1.

Implementation 2:

Again, let S1 and S2 be the two stacks to be used in the implementation of our queue. As in the previous implementation we have to define enqueue and dequeue operations.

            if (S1 is empty & S2 is empty) return(error);

            if (S2 is empty){

                        while( S1 is not empty){

                                    S2.push( S1.pop());

                        }

            return( S2.pop());

Programming Problem 3 : Use your stack implementation to implement a queue using the above pseudocode . Implement the queue interface defined here . Name this implementation myQueue2.

Analysis Problem 1 (not to be submitted) : Argue for yourself that the above two correctly implements a queue using two stacks.

Analysis Problem 2 (not to be submitted) : Try to figure out why the second implementation is much better than the first one.

Parallel Programming

This is an important programming paradigm where you can run multiple “threads” of execution in parallel. Parallel programming is useful in reducing the running time, or deal with asynchronous inputs, or sometimes just to model the problem in a better manner. Here we will use Java threads to get a taste of parallel programming.

Programming Problem 4 : You have to create multiple java threads (number of threads will be specified as input). Each thread will read from a separate file and execute the operation on a shared queue. You have to use the queue that you have made in programming problems 2 and 3. The implementation you have to use will be specified in the input. Note that you should make proper use of synchronization.

Input-output format for programming problems 4 : Programming problem 4 should use your implementations in programming problems 1 ,2 , and 3. We will not specifically check your implementation of programming problems 1 ,2 , and 3.

Program name : You must write a Simulate.java program which contains the main method. This is the program that we will run to check your implementations.

Input : Your program should take two command line arguments that are both integers. The first argument denotes the number of threads your program should run. The second argument tells you which implementation of a queue (myQueue1 or myQueue2) you should be using. For example, consider that you run the following command:

This means that you must run 5 threads and use your 1 st queue implementation (i.e., myQueue1).

The queue operations must be read from files named operations-x.dat . For example if there are 5 threads, thread 1 reads from operations-1.dat file, thread 2 reads from operations-2.dat file and so on. Each file contains enqueue and dequeue statements in separate lines. Following is an example of an operations-x.dat file:

<a>, <b>, etc. denote arbitrary strings.

Output : Your program should output two files. First it should produce a file named operations-out.dat which should contain the enqueue / dequeue operation and the thread number which executes this operation. For example suppose thread #1 executed enqueue ( a), dequeue (), enqueue (b), and then thread #2 executed dequeue (). Then your operations-out.dat file should be the following:

Your second file should be named output.dat and it should contain the output of the dequeue operations performed on the shared queue and the thread number performing the operation. For example, corresponding to the above operations-out.dat file, your output.dat file should be the following:

Your program must handle the errors in input file format as exception. These must be caught and reported on standard output as "FileFormatException".

Empty stack errors : In case of errors, for example, the queue is empty and there is a dequeue request. The output.dat file should contain the appropriate exception name for that request. For example, there is a single thread and the input file operations-1.dat is the following:

Then the output.dat file should look like:

BTech Geeks

Data Structures Question Bank With Answers PDF Free Download

Data Structures Question Bank With Answers PDF: Are you a student and facing trouble in finding the right questions for your preparation for data structures exam? Students can overcome this problem just by downloading the data structures question bank with answers PDF, and it will eliminate all the troubles. It will make the preparation of the students more efficient.

Data structures question bank with answers PDF helps the students to gain a piece of detailed knowledge of data structures, and this will strengthen the core knowledge of the students. With a strong base, students can secure good marks in the exams. Data structures question bank with answers PDF is prepared to keep in mind the syllabus of data structures so that the students can precisely follow the curriculum.

Students can get access to some of the best reference books of the data structure and Lecture Notes from this article which will help them in enhancing their preparation.

  • About data structures
  • Data structures question bank with answers PDF
  • Data structures reference books.
  • Data structure syllabus
  • Data structure important Questions.
  • Frequently asked questions

About Data Structures Question Bank With Answers

The data structure, in computer science, is defined as a data organisation, management, and storage format that allows efficient access and modification. In simpler words, data structures can be termed as the collection of data values, the relationship prevailing among them and the functions and operations that are possible to be applied to the data.

They are the basis of Abstract Data Types (ADT). The ADT is used to define the logical form of data type, whereas the data structure describes the physical form of a data type. Data structures are of different types and are suited for different kind of applications, and some are also highly specialised for specific tasks only. Data structures provide a medium to manage a large amount of data efficiently for uses such as databases and internet indexing services.

Data structure generally depends on the capability of the computer in fetching and storing data inside the memory of computer, which is to be specified by a pointer. The implementation of data structure generally requires to write a set of procedures that would create and manipulate the instances of a particular structure. It is not possible to analyse the efficiency of data structure separately from the operations.

All these concepts and basics can be learned from the data structures question bank with answers PDF as it includes questions that have the ability to give a detailed overview of a data structure without any doubt.

Students facing problems in the data structure chapter must download data structures question bank with answers PDF to get a clear overview of the chapter. The questions in the PDF will help students in enhancing their preparation for the exams. An efficient preparation for the exams can result in the scoring of good marks in the exams.

The questions included in the data structures question bank with answers PDF helps the students by giving them a preview of the problem they are going to face in the exams thus motivating them to get prepared according to it. This PDF will wash away all the weaknesses of the students and will help them to strengthen their cores.

  • Data structures notes PDF
  • Data structures lecture notes
  • Data structures study materials
  • Data structures questions PDF
  • Data structures PPT
  • Data Structures Important Questions And Answers Pdf
  • Data Structure Question Paper With Answer Pdf
  • Data Structures Question Bank With Answers Pdf
  • Data Structures And Algorithms Question Bank With Answers Pdf
  • Data Structures Important Questions Pdf
  • Data Structure Important Questions And Answers Pdf
  • Data Structure Questions And Answers Pdf Free Download
  • Dsa Question Bank Pdf
  • Data Structures Questions And Answers Pdf
  • Data Structure Question Paper With Answer
  • Data Structure Questions And Answers Pdf
  • Data Structures And Algorithms Important Questions Pdf
  • Data Structures And Algorithms Questions And Answers Pdf

Data Structure Important Questions

  • Data Structures And Algorithms Interview Questions And Answers Pdf
  • Data Structure Question Paper Pdf
  • Dsa Questions And Answers Pdf
  • Data Structures University Questions And Answers
  • Data Structures Important Questions And Answers
  • Advanced Data Structures And Algorithms Question Bank With Answers
  • Dsa Interview Questions And Answers Pdf

Data Structures Reference Books

Books are the best source of gaining knowledge on a particular topic. They give the students a detailed view of the topic, which help them to strengthen their cores. A book can help the students to enhance his/her preparation for the exams and become confident of scoring good marks in the exams.

Referring to one book is not always enough because one book cannot give all the information related to a particular topic. A student who is interested in scoring good marks must try referring more than one books for his/her own benefits.

There are some books of data structures that are considered as best by some experts who have years of experience in this field. Students should refer this books during their preparations. Some of these books are:-

  • Introduction to Algorithms by Thomas H. Corman
  • Algorithms by Robert Sedgewick & Kevin Wayne
  • The Algorithm Design Manual by Steve S.Skiena
  • Algorithms For Interview by Adnan Aziz
  • Algorithms in Nutshell by O’Reilly’s
  • Algorithm Design  by Kleinberg & Tardos
  • The Design and Analysis of Computer Algorithms by Alfred Aho, Jeffrey Ullman, John Hopcraft
  • Data Structures and Algorithms by Aho, Ullman & Hopcraft
  • Python Algorithms: Mastering Basic Algorithms in the Python Language by some Python Programmers

Data Structures Syllabus

Students should know the pattern of questions that are coming in the exams. They should learn from which section of the subject most of the questions are coming from. This will help them in their preparation and make them more confident for the final exams. A confident student can easily score the highest possible marks in the exams.

Let us list out some of the important questions that can help a student to enhance his/her preparation and becoming more efficient on this particular chapter data structure:-

  • What is the data structure?
  • Difference between file structure and storage structure
  • When is a binary search best applied?
  • What do you mean by linked list?
  • In what areas data structures can be applied?
  • What do you understand by LIFO?
  • What is the queue?
  • What do you mean by binary trees?
  • Which data structures are meant to be applied while dealing with a recursive function?
  • What do you mean by a stack?
  • Explain binary search tree
  • What are multidimensional arrays?
  • What can be linked lists considered as: linear or non-linear data structures?
  • List the ways how dynamic memory allocation helps in managing data
  • What do you understand by FIFO?
  • What is an ordered list?
  • What do you understand by merge sort?
  • Differentiate between NULL and VOID
  • List out the primary advantages of linked list.
  • What’s the difference between a PUSH and a POP?
  • What is a linear search?
  • How does the variable declaration affect memory allocation?
  • List out the advantages that can come when the heap is over a stack
  • What do you understand by postfix expression?
  • What does data abstraction mean?
  • How to insert a new item in the binary search tree?
  • What are the ways in which a selection sort works for an array?

Data structures question banks with answers PDF can act as a saviour for the students in their final exams. They can increase their knowledge and be experts in this subject with the help of this PDF. The reference books mentioned in this article are trusted to be valuable and have the capability of giving the students a detailed knowledge. The questions mentioned above are some of the important questions that are likely to come in the exams; thus, students should prepare it efficiently. Students can achieve success with this PDF.

Also Refer: Multiple Bus Organisation Notes and Study Material PDF Free Download

Frequently Asked Questions on Data Structure Question Bank With Answers

Question 1. What are the advantages of data structures?

Answer: Some of the advantages of data structures are

  • It allows information storage on hard disks.
  • It provides means of management for large datasets, for example, databases or internet indexing services.
  • It is required for designing efficient algorithms.
  • It allows security to storage by providing safe storage of information on a computer.
  • It helps in data usage and processing on a software system.
  • Processing of data can be much easier with the data structure.
  • In the data structure, a person can access the data anytime at any place using the internet, which is a beneficial aspect of data structuring.

Question 2. What are the disadvantages of data structure?

Answer: Some of the important disadvantages of the data structure are:-

  • Applications which are using data structure for operations requires a highly qualified professional resource that can manage the operations related to the data structure easily. Acquiring this professional resource is very difficult.
  • If the data structure used to maintain and control the application is more significant, then it must require a lot of workforces. Increase in labour cost will make data structure operations expensive.
  • Designing a data structure is very difficult as it involves a complex algorithm. It will require a lot of time and testing to prove that it is ready to be used in a organisation.

Question 3. What is a binary tree in data structure?

Answer: Binary tree in computer science can be defined as a tree data structure in which each node consists of at most two children. These two children are referred to as the left child and the right child. The binary tree sometimes is also interpreted as an undirected rather than as a directed graph. In these cases, the binary tree is an ordered and rooted tree. Some authors also use a rooted binary tree in spite of the binary tree to emphasise on this particular fact.

Question 4. What do you understand by a linked list?

Answer: Linked list is defined as a collection in a linear way of data elements whose orders are not mentioned by their physical placement in the memory. Instead, in this case, each element points to the next element. This is a type of data structure that consists of a collection of nodes which together can be represented as a sequence.

  • Computer Science and Engineering
  • Data Structures And Algorithms (Video) 
  • Co-ordinated by : IIT Delhi
  • Available from : 2009-12-31
  • Introduction to Data Structures and Algorithms
  • Queues and Linked Lists
  • Dictionaries
  • Tree Walks / Traversals
  • Ordered Dictionaries
  • Red Black Trees
  • Insertion in Red Black Trees
  • Disk Based Data Structures
  • Case Study: Searching for Patterns
  • Data Compression
  • Priority Queues
  • Binary Heaps
  • Why Sorting
  • More Sorting
  • Data Structures for Graphs
  • Two Applications of Breadth First Search
  • Depth First Search
  • Applications of DFS
  • DFS in Directed Graphs
  • Applications of DFS in Directed Graphs
  • Minimum Spanning Trees
  • Prims Algorithm for Minimum Spanning Trees
  • Single Source Shortest Paths
  • Correctness of Dijkstras Algorithm
  • Watch on YouTube
  • Assignments
  • Transcripts

data structure assignment questions

Online Embedded Systems Course with Placements

Advanced Embedded Course With Placements

Advanced Embedded Course With Placements

Online Embedded IoT Course

Online Embedded IoT Course

Advanced Embedded IoT Course With Placements

Advanced Embedded IoT Course With Placements

Linux Device Drivers

Linux Device Drivers

Embedded

IoT Internship

Campus Ambassador Program

Campus Ambassador Program

  • For Corporates
  • All Courses
  • Hire Trainees
  • Short-term Courses

Schedule a Call

With Our Career Counsellor

Invalid value

  • Register now!
  • DSA Tutorial
  • Data Structures
  • Linked List
  • Dynamic Programming
  • Binary Tree
  • Binary Search Tree
  • Divide & Conquer
  • Mathematical
  • Backtracking
  • Branch and Bound
  • Pattern Searching
  • 30 OOPs Interview Questions and Answers (2024)
  • C++ Interview Questions and Answers (2024)
  • Top 100 C++ Coding Interview Questions and Answers (2024)
  • Top 50+ Python Interview Questions and Answers (Latest 2024)
  • Java Interview Questions and Answers
  • Java Collections Interview Questions and Answers
  • Top 20 Java Multithreading Interview Questions & Answers

Top 100 Data Structure and Algorithms DSA Interview Questions Topic-wise

  • Top 50 Array Coding Problems for Interviews
  • Most Asked Problems in Data Structures and Algorithms | Beginner DSA Sheet
  • Top 10 Algorithms in Interview Questions
  • Machine Learning Interview Questions
  • Top 50 Problems on Linked List Data Structure asked in SDE Interviews
  • Top 50 Problems on Heap Data Structure asked in SDE Interviews
  • Data Analyst Interview Questions and Answers
  • SQL Query Interview Questions
  • Top Linux Interview Questions With Answer
  • MySQL Interview Questions
  • Top 50 Django Interview Questions and Answers
  • Top 50 Networking Interview Questions (2024)
  • Software Testing Interview Questions

DSA has been one of the most popular go-to topics for any interview, be it college placements, software developer roles, or any other technical roles for freshers and experienced to land a decent job. If you are among them, you already know that it is not easy to find the best DSA interview questions among the vast pool of available problems. So here we are, with the Top 100 most asked DSA interview questions to help you sail through your technical rounds.

Top 100 Data Structure and Algorithms (DSA) Interview Questions Topic-wise

Top 100 Data Structure and Algorithms (DSA) Interview Questions Topic-wise

Table of Content

DSA Interview Questions on Array

Dsa interview questions on matrix, dsa interview questions on string, dsa interview questions on linked list, dsa interview questions on stack & queue, dsa interview questions on tree, dsa interview questions on heap, dsa interview questions on graph, dsa interview questions on dynamic programming, dsa interview questions on bit manipulations.

In this Top 100 DSA interview questions, we have segregated the problems based on the Data structure or algorithm used to solve them . Without further delay, let us begin your interview preparations:

  • Check if pair with the given Sum exists in Array
  • Best Time to Buy and Sell Stock
  • Find duplicates
  • Product of Array Except Self
  • Maximum Subarray
  • Maximum Product Subarray
  • Find Minimum in Rotated Sorted Array
  • Search in Rotated Sorted Array
  • Container With Most Water
  • Find the Factorial of a large number
  • Trapping Rain Water
  • Chocolate Distribution Problem
  • Insert Interval
  • Merge Intervals
  • Non-overlapping Intervals
  • Set Matrix Zeroes
  • Spiral Matrix
  • Program to find the transpose of a matrix
  • Word Search
  • Longest Substring Without Repeating Characters
  • Longest Repeating Character Replacement
  • Smallest window in a String containing all characters of other String
  • Check whether two Strings are anagram of each other
  • print all anagrams together
  • Check if given Parentheses expression is balanced or not
  • Sentence Palindrome
  • Longest Palindromic Substring
  • Palindromic Substrings
  • Longest Common Prefix
  • Reverse a Linked List
  • Detect Cycle in a Linked List
  • Merge Two Sorted Lists
  • Merge K Sorted Lists
  • Remove Nth Node From End Of List
  • Reorder List
  • Add 1 to a number represented as linked list
  • Find the middle of a given linked list
  • Delete last occurrence of an item from linked list
  • Convert Infix expression to Postfix expression
  • Next Greater Element
  • Delete middle element of a stack
  • Check mirror in n-ary tree
  • The Celebrity Problem
  • Length of the longest valid substring
  • Print Right View of a Binary Tree
  • Find the first circular tour that visits all petrol pumps
  • Maximum Depth of Binary Tree
  • Check if two trees have same structure
  • Invert/Flip Binary Tree
  • Binary Tree Maximum Path Sum
  • Binary Tree Level Order Traversal
  • Serialize and Deserialize Binary Tree
  • Subtree of Another Tree
  • Construct Binary Tree from Preorder and Inorder Traversal
  • Validate Binary Search Tree
  • Kth Smallest Element in a BST
  • Lowest Common Ancestor of BST
  • Implement Trie (Prefix Tree)
  • Add and Search Word
  • Top K Frequent Elements
  • Find Median from Data Stream
  • Largest triplet product in a stream
  • Connect n ropes with minimum cost
  • Clone Graph
  • Course Schedule
  • Pacific Atlantic Water Flow
  • Number of Islands
  • Longest Consecutive Sequence
  • Snake and Ladder Problem
  • Detect Cycle in a Directed Graph
  • Bridges in a graph
  • Check whether a given graph is Bipartite or not
  • Find size of the largest region in Boolean Matrix
  • Flood fill Algorithm
  • Strongly Connected Components
  • Topological Sorting
  • Count ways to reach the n’th stair
  • Coin Change
  • 0/1 Knapsack Problem
  • Longest Increasing Subsequence
  • Longest Common Subsequence
  • Word Break Problem
  • Dice Throw 
  • Egg Dropping Puzzle
  • Matrix Chain Multiplication
  • Combination Sum
  • Subset Sum Problem
  • Find maximum possible stolen value from houses
  • Count Possible Decodings of a given Digit Sequence
  • Unique paths in a Grid with Obstacles
  • Cutting a Rod
  • Maximum Product Cutting
  • Count number of ways to cover a distance
  • Number of 1 Bits
  • Counting Bits
  • Missing Number
  • Reverse Bits
  • Find XOR of all subsets of a set

Related posts:

  • Commonly Asked Data Structure Interview Questions
  • Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, …

Some other important Tutorials:

  • System Design Tutorial
  • Software Development Roadmap
  • Roadmap to become a Product Manager

Please Login to comment...

  • interview-preparation
  • interview-questions
  • 10 Best Free Social Media Management and Marketing Apps for Android - 2024
  • 10 Best Customer Database Software of 2024
  • How to Delete Whatsapp Business Account?
  • Discord vs Zoom: Select The Efficienct One for Virtual Meetings?

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Solutions to Data Structure Assignment Questions | Homework Help for Computer Science Students

What type of service are you looking for, tough essay due hire tough essay writers.

We have subject matter experts ready 24/7 to tackle your specific tasks and deliver them ON TIME, ready to hand in. Our writers have advanced degrees, and they know exactly what’s required to get you the best possible grade.

Profile picture of ProfWriter

Staff Level Intermediate

Total orders 7134

Profile picture of ProfWriter1

ProfWriter1

Total orders 3848

Profile picture of Revaz Pataradze

Revaz Pataradze

Staff Level Elite

Total orders 1020

Profile picture of Pro. Nicole

Pro. Nicole

Staff Level Advanced

Total orders 1026

Profile picture of Nicole Ashton

Nicole Ashton

Total orders 1197

Profile picture of Prof. Jordan

Prof. Jordan

Total orders 1539

Profile picture of Andrea Gibson

Andrea Gibson

Total orders 1710

Profile picture of Hanna preston

Hanna preston

Total orders 2223

Profile picture of Gilbert Rights

Gilbert Rights

Total orders 1005

Profile picture of Dr. Payne

Total orders 1836

Find the right expert among 500+

We hire Gradewriters writers from different fields, thoroughly check their credentials, and put them through trials.

Homework Help for Data Structure Assignment Questions

If you're a computer science student, or maybe you're just a programming enthusiast, you may be aware of the importance of data structures. Typically, data structures form the basics of programming and are not very challenging. But like any other new concept, they may seem confusing and hard to understand when getting started. But with time and consistency, you eventually get to the top.

As a student of data structures, you need to practice data structure questions and answers consistently and consult with your peers to ensure that you capture every concept. You can also request expert help for your data structure assignment questions if you don't understand certain concepts.

At GradeWriters, our mission is to help newbies get their feet off the ground in programming through our data structures assignments help program. Or maybe an experienced programmer who doesn't have time to handle all their data structures assignments , even though they know how to handle them.

But for a beginner:

What Is Data Structure?

In programming, a data structure can be considered a container where related data is stored when writing programs. Basically, we use data structures to keep our programs organized and well-formatted for ease of readability and efficiency. Thus, data structures form an integral part of all programming languages and the entire computer science ecosystem.

For instance, if you've been asked to write a programming assignment that stores data about the names and number of members of your class as well as their ages, it would be efficient to store the two components in separate objects (we'll learn about them shortly). Then, assuming you're 40 members, you only need one object to store all that—instead of assigning each of them a variable.

Again, it becomes much easier to access and modify the elements individually. That helps write programs per the popular "Don't Repeat Yourself" (DRY) principle, a great programming practice. And, of course, that's what we follow in all our programming assignment help services .

Before delving into the different data structures used in programming, it's important to understand another related term—data types.

Data Types Explained

A data type in programming refers to the attributes given to the different program elements to tell the compiler what the elements are and how they should be interpreted. For instance, a full number like 50 is called an integer, while a sentence like "My name is John Doe" is called a string (in most programming languages).

5 Common Data Types

  • Integer, e.g., 0, 1, 2, 3,...
  • Double/Floating-point numbers, e.g., 0.1, 0.2, 0.3, 0.4,...
  • String, e.g., "I am John Doe."
  • Boolean- either True or False
  • Character, e.g., a, b, c, d,...

Basic and Key Data Structures in Programming

They can be classified into two:

  • Linear Data Structures, e.g., Arrays, Linked Lists, Unions, Structures, and stacks.
  • Non-Linear Data Structures, e.g., trees, hash tables, graphs.

Before you learn more about linear and non-linear data structures , make sure to give us a call if you have exceptional data structure assignment help.

Linear Data Structures

A linear data structure implies that data elements are arranged sequentially. Also, each element is connected to the previous and next elements.

An array is a data structure used to hold/store items of the same data type. For instance, in the previous examples about your classmates, you can store them in a single array because they are all strings. The same applies to their ages (integers). Each item in the array is called an element.

An array will always have the zero-based indexing feature in all programming languages, which is critical in how the different elements are accessed. The binary search concept is also used in accessing the elements. Note that an array can store all the different data types we have just mentioned, provided they are all the same types.

Our data structure assignment help covers all these concepts. Hire our homework help writers today to learn more about data structures and get good grades in the same.

Linked List

A linked list is a data structure made of elements called nodes, each of which comprises two parts—the node data and a pointer to the next node. That tells you a linked list is dynamic, where each node connects to the next via a pointer.

For instance, if you've been assigned writing a program that uses a linked list, you may think of a queue. Practically, members in a queue are interconnected, and each of them can be considered a node.

Besides queues, you may think of implementing a stack. They all use the same principle—a linked list. If you have some challenging linked list that you'd want to consult, our data structure assignment help program is open for you.

Unions and Structures

If you have done C programming language , chances are you've been introduced to structs. Now, unions are similar to structs, only that they have a special feature that allows you to store multiple data types in the same memory location (for reference purposes).

Note that only one data type can occupy the memory location at a given time—they cannot be stored simultaneously. From our experience, most students struggle with data structure assignments related to unions and structs, but they aren't as tough. Therefore, you only need experts to offer you data structure assignment help or recommend some model papers.

In data structures and algorithms, a stack is a structure that applies the ordinary stacking technique, where we can only add or remove an element from the top only. For instance, in a stack of cards or plates, you cannot remove one from the sides—you have to remove or add from the top.

However, most programming assignments using this technique tend to be challenging, even for an experienced student. But what students need to know is, every assignment is doable! Just connect with a good team of experts and ensure the best data structures and algorithms assignments service.

Non-Linear Data Structures

Non-linear data structures have no particular sequence of connecting their elements. On the other hand, linear data structures, such as arrays, support zero-based indexing and binary search because they are ordered. And of course, in graphs and trees, traversal cannot be done once through all elements, a feature that makes them useful in multi-level storage.

Got Data Structure Assignment Questions? Use Our Homework Help Services

What we have discussed above is just a portion of what your data structure assignment may cover. But regardless of the diversity of the concepts, we have experts who can write quality papers to earn you excellent grades.

If you're a student looking for a secure online platform that delivers plagiarism-free data structures assignments, completes your project in time, and provides the correct solution to your challenging data structure assignment, GradeWriters is the place to be.

Contact our support team for any questions, or head over to the order page and send us your request

  • View writers
  • View Samples

Profile photo of ProfWriter

Do you need help with an online class, essay or assignment?

We hire Custom Writing Bee writers from different fields, thoroughly check their credentials, and put them through trials.

An image of students looking at a laptop screen

COMMENTS

  1. PDF Cs8391-data Structures Question Bank Unit I

    Formally data structure can be defined as a data structure is a set of domains D, a set of domains F and a set of axioms A. this triple (D,F,A) denotes the data structure d. 2. What do you mean by non-linear data structure? Give example. The non-linear data structure is the kind of data structure in which the data may be

  2. Top 50 Data Structures MCQs with Answers

    Question 2. Which one of the following is an application of Queue Data Structure? When a resource is shared among multiple consumers. When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes. Load Balancing. All of the above. Top MCQs on Queue Data Structure with Answers Top 50 Data ...

  3. Solve Data Structures

    Data Structures. Data Structures. Arrays - DS. Easy Problem Solving (Basic) Max Score: 10 Success Rate: 93.21%. Solve Challenge. 2D Array - DS. Easy Problem Solving (Basic) Max Score: 15 Success Rate: 93.15%. Solve Challenge. Dynamic Array. Easy Problem Solving (Basic) Max Score: 15 Success Rate: 86.81%.

  4. Data Structures & Algorithms Guide for Developers

    Data Structures and Algorithms are foundational concepts in computer science that play a crucial role in solving computational problems efficiently. Data structures are organized and stored in formats to enable efficient data manipulation and retrieval. They provide a way to organize and store data so that operations can be performed efficiently.

  5. Data Structures Tutorial

    Data structures are essential components that help organize and store data efficiently in computer memory. They provide a way to manage and manipulate data effectively, enabling faster access, insertion, and deletion operations. Common data structures include arrays, linked lists, stacks, queues, trees, and graphs , each serving specific purposes based on the requirements of the problem at hand.

  6. Assignment 4: Stacking Queues

    The fourth assignment is mostly about stacks and queues. For the former you'll build a simple calculator application, for the latter you'll implement the data structure in a way that satisfies certain performance characteristics (in addition to the usual correctness properties). Problem 1: Calculating Stacks (50%)

  7. Data Structures

    Module 1 • 4 hours to complete. In this module, you will learn about the basic data structures used throughout the rest of this course. We start this module by looking in detail at the fundamental building blocks: arrays and linked lists. From there, we build up two important data structures: stacks and queues.

  8. PDF Question Bank

    A data structure is a way of organizing data that considers not only the items stored, but also their relationships to each other. C203.1 BTL1 2 Why do we need data structures? Data structures allow us to achieve an important goal: component reuse. Once data structure has been implemented, it can be used again and again in

  9. Assignments

    There will be a weekly one-page assignment, 10 assignments in total. You may skip any one problem, or we will ignore the problem with the lowest grade. If you volunteered to scribe twice, we will ignore the lowest two grades. The answers must be typeset in LaTeX. The answers must fit in one page, or your solution will not be read. Use at least ...

  10. Data Structures Assignment 1

    The goal of this assignment is to implement a queue using two stacks. We will employ two different ideas for this and try to understand why one idea is better than the other. Let us first consider a naive implementation. Implementation 1: Let S1 and S2 be the two stacks to be used in the implementation of our queue.

  11. PDF Assignment 9: Data structures

    1 Choosing data structures In the lecture you have learnt that di erent data structures can represent di erent kinds of information and support e cient implementation of di erent operations. To do 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 ...

  12. PDF ESO207A: Data Structures and Algorithms End-semester exam

    ESO207A: Data Structures and Algorithms End-semester exam Max marks: 120 Time: 180 mins. 17-July-2017 1.Answer all 7 questions. Questions 1 to 3 are from module 3 and questions 4 to 7 are from module 4. Each module is worth 60 marks. The question paper has 4 pages. 2. Answer all parts of a question together. Do not scatter them across the ...

  13. Python Data Structure Exercise for Beginners

    This data structure exercise is for beginners to understand and practice basic data structure in Python. Practice Python List, Set, Dictionary, and Tuple questions. The data structure is widely used to hold any data. To perform any programming tasks in Python, good knowledge of data structure is a must. Solve this exercise to have a good ...

  14. PDF UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

    Q 2. Create a structure/class for a group of 50 students holding data for their Regn no., Name, Branch, CGPA a) Call linear search function to display data of student with a particular Regn no.. b) Call bubble sort function to arrange data of students according to Regn no. c) Apply binary search on the above output (part b) to display data of a

  15. CPSC 327: Data Structures and Algorithms

    This assignment is due next Wednesday, February 11. After finishing Chapter 2, we will move on to another abstract data type, the priority queue. We will see how the heap data structure can be used to implement priority queues. We will also use heaps to implement the efficient sorting algorithm known as HeapSort.

  16. Data structure

    Mahaveer College of Commerce Pre university examination B.C Part III Data Structure(using C/C++) Examination-2017-Time Allowed: three hours Max. Marks: 100 All the parts of one question should be answered at one place in the answer-book. One complete question should not be answered at different places in the answer- book.

  17. Data Structures Question Bank With Answers PDF Free Download

    Students facing problems in the data structure chapter must download data structures question bank with answers PDF to get a clear overview of the chapter. The questions in the PDF will help students in enhancing their preparation for the exams. An efficient preparation for the exams can result in the scoring of good marks in the exams.

  18. Computer Science and Engineering

    Courses. Computer Science and Engineering. Data Structures And Algorithms (Video) Syllabus. Co-ordinated by : IIT Delhi. Available from : 2009-12-31. Lec : 1. Watch on YouTube. Assignments.

  19. Commonly Asked Data Structure Interview Questions

    Advantages: Constant time access, simple implementation, and efficient storage for contiguous data. Disadvantages: Fixed size, no support for dynamic growth, inefficient for insertions and deletions. Question 12: Explain the concept of a sparse array. Answer: A sparse array is an array in which most of the elements have the same value. It can be represented using a data structure that only ...

  20. PDF Data Structures and Algorithms: Assignment 3

    Data Structures and Algorithms: Assignment 3 Maximum points you can get from Assignment 3 is 130 points (100 points + 30 points BONUS). Distribution of points within questions has been given in parentheses below. • Criteria to pass "Assignments" sub-course (3.5 HEC): From each assignment (i.e. Assignment #1, Assignment #2 and Assignment#3) you have to get minimum 50 points (out of

  21. Data Structures

    Welcome to Data Structures, CS112. After completing the course the student will be able to: ... We use the Java programming language for all assignments and exams in the course. ... Rather than emailing questions to the teaching staff, we encourage you to post your questions on Piazza. If you have any problems or feedback for the developers ...

  22. Data Structures Assignments

    By solving these assignments, you will go through a systematic problem-solving approach which include requirement understanding, algorithm design, pseudocode creation, dry run and final execution. As you move from simple to more complex assignments of each module it will slowly start building your self-confidence. Chapter1 : Single Linked List.

  23. Top 100 Data Structure and Algorithms DSA Interview Questions Topic

    DSA Interview Questions on Tree. Maximum Depth of Binary Tree. Check if two trees have same structure. Invert/Flip Binary Tree. Binary Tree Maximum Path Sum. Binary Tree Level Order Traversal. Serialize and Deserialize Binary Tree. Subtree of Another Tree. Construct Binary Tree from Preorder and Inorder Traversal.

  24. Homework Help for Data Structure Assignment Questions

    As a student of data structures, you need to practice data structure questions and answers consistently and consult with your peers to ensure that you capture every concept. You can also request expert help for your data structure assignment questions if you don't understand certain concepts. At GradeWriters, our mission is to help newbies get ...