Data Structures: Question Set – 01

Data Structures: Question Set – 01

What are Data Structures?

The mechanical or logical way in which data is organised within a programme is referred to as a “data structure.” The efficiency of the software is directly proportional to how well its data are organised. There are many different kinds of data structures, and each one serves a particular purpose. When we are building the code for a programme, we need to pay close attention to the way in which the data is organised. If the data is not saved appropriately or in an efficient manner, then the overall performance of the code will suffer.

Why Create Data Structures?

Within a computer programme, data structures are vitally important for a variety of reasons. They help the programmer detect and fix errors with his or her code, they contribute to the creation of a code base that is clear and organised, and they ensure that each line of code performs its function correctly and effectively.

Differentiate: File structure and Storage structure

  • File Structure is data representation into secondary or auxiliary memory, such as any device such as a hard disc or pen drive that stores data that remains intact until it is manually deleted. A file structure representation is known as the “representation of data into secondary or auxiliary memory.”
  • Storage Structure: Information of this kind is kept in the primary memory, also known as RAM, and is discarded once the operation that makes use of the data has been carried out in its entirety.
  • The data for the storage structure is kept in the main memory of the computer system, but the data for the file structure are kept in auxiliary memory. This is the key distinction between the two structures.

Explain various types of data structures

  • Linear Data Structure: A linear data structure is a type of data structure that contains data elements that are arranged sequentially or linearly, where each element is connected to its previous and next nearest elements. This type of data structure also includes data elements that are connected to one another. Examples of linear data structures include arrays and linked lists, as well as other similar structures.
  • A non-linear data structure is a data structure in which the data elements are not ordered in a linear or sequential fashion. Non-linear data structures are a type of data structure. In a non-linear data structure, we are unable to go through all of the elements in a single pass as we would in a linear data structure. Non-linear data structures can take the form of trees and graphs, for instance.

State few applications of datatypes

The following are some examples of applications of data structures that take place in real time:

  • Image processing and pattern recognition
  • Genetics and evolutionary algorithms
  • Compiler design
  • Database management
  • Numerical analysis and statistical processing
  • Decision making
  • Blockchain
  • Software design and problem solving

What is array data structure? What are the applications of arrays?

A data structure known as an array data structure is one that is utilised to store data in a manner that is both effective and simple to access when required. It keeps information in a sequential fashion, much like a list does, hence it is comparable to a list. However, in contrast to a list, a data structure known as an array may store a great deal more information than can be contained in a list. Combining many arrays into one another results in the creation of a data structure known as an array. After that, an exclusive identifier is assigned to each array, and the data for each array is saved in the sequence in which the arrays were generated.

In order to store vast volumes of data quickly and effectively, databases and other types of computer systems frequently make use of array data structures. They can also be used to store information that is requested frequently, such as vast volumes of text or photos, which is another important application for them.

What is a stack? State few applications of stack

A data structure known as a stack is employed for the purpose of illustrating the current state of an application at a particular instant in time. The stack is made up of a series of things, each of which has had one or more placed on top of it before being removed from that position. It is a data structure known as a linear database that adheres to a predetermined sequence in which operations are carried out. Two different orders are “Last In First Out” (LIFO) and “First In Last Out,” sometimes known as “FILO.” A stack is made up of one item after another in sequential order. The component that was added very recently will be the one that is removed first; a real-world example of this would be a pile of garments piled on top of one another. It is possible to claim that the piece of fabric that was added most recently is the one that is removed first when the piece of cloth that was previously on top is removed.

Listed below are some applications that make use of the stack data structure:

  • Function calls order
  • Reversing a string
  • Storing browser history
  • It acts as temporary storage during recursive operations
  • Redo and Undo operations in doc editors
  • Parenthesis matching
  • Postfix to Infix Expressions
  • Evaluating expressions

Discuss various operations on stack

The following is a list of the primary operations that are offered by the stack data structure:

  • push: This adds an item to the top of the stack. The overflow condition occurs if the stack is full.
  • pop: This removes the top item of the stack. Underflow condition occurs if the stack is empty.
  • top: This returns the top item from the stack.
  • isEmpty: This returns true if the stack is empty else false.
  • isFull: This returns true if the stack is full else false.
  • size:  This returns the size of the stack.