In this tutorial, we will discuss about data structures from the basics. We will understand the different types of data structures and their uses and how we can implement them.
List of Topics:
What is data structure?
A data structure is a collection of data that can be stored in an organised manner so that the data can be accessed, modified efficiently.
Data Structures usages
- Data structures are used in different kinds of applications like relational databases, which use B-tree indexes to retrieve the data.
- Hash table is used in compiler design.
- These are used in different algorithms like searching, sorting.
- Internet indexing service uses data structures.
Types of the Data structures
|Types of DS||Sub type|
|Binary Search Tree|
What is Linear data structure ?
A linear data structure is a type of data structure where data can be traversed sequentially. Array, Linked list, stack, queue are examples of linear data structure. Please go through below image for the details:
What is Tree Data Structure
A tree data structure is a hierarchical data structure. It has nodes that are connected by edges.Please go through below image for the details:
What is hashing
Hashing is a data structure which uses a hash function to map the data in a key-value pair to retrieve the data faster. Examples of Hashing are Hash table, Hash tree. Please go through below image for the details:
What is graph
A Graph is a non-linear, pictorial representation of data consisting of edges and vertices. Please go through below image for the details:
Difference between linear and non-linear data structure
|Sl No||Key points||Linear data structure||Non-linear data structure|
|1||Data alignment||Data gets stored sequentially||Data gets stored in hierarchy form|
|2||Levels||Single level involved||Multiple level involved|
|3||Complexity||Easy to implement||Implementation is complex|
|4||Traversal||Data can be traversed in single run||Data cannot be traversed in a single run rather need multiple runs|
|5||Utilisation of memory||Not efficient||Efficient|
|6||Examples||Array, Linked list, stack, queue||Graph, tree|
|7||Application||Used in software development||Used in Image Processing, Voice Processing, Artificial Intelligence|
Some import Questions and Answers on Data Structure
Qn 1. What do you mean by ADT in Data structure?
Ans: ADT means Abstract Data type. Class or Objects are an example of ADT. When We use and Class or Object, we define the behavior by a set of values and a set of operations. ADT only tells us what operation has to perform. It does not tell us how the operation has been internally implemented.
For Example :
- size() -> Size gives us the number of elements, but it does not show how internally it calculates to give the result.
- insert(x) -> insert helps us to insert the element but does not tell how the logic is written.
- remove(x) -> Similarly remove method is used to remove the elements without telling the implementation.
- get(i) -> get is used to access the elements.
Qn 2. What are the advantages of data structure?
- Using Data Structure, we can efficiently store data in a storage device.
- Data structure gives an easy option to retrieve the data from a storage device.
- It can process small as well as large numbers of data efficiently
- Using data structures like graph we can solve real-life problems
- Database systems uses indexing using a hash table and array to retrieve the data efficiently.
Qn 3. What is primitive data structure?
Ans: Primitive data structures are system-defined data types supported by different programming languages. Example: int, double, float, boolean, character.
Qn 4. What is a Complex Data structure?
Ans: Data structures like Hash table, Tree, Heap, Graph are called a complex data structure. The implementation of these data structures is complex in nature.
Qn 5. What are the two main types of data structure?
Ans: Mainly, data structures are divided into two parts:
- Linear Data structure: Stack, Queue, Array, Linked List
- Non-linear Data Structure: Tree, Graph
One of the best practices in test automation is separating the test data from the test files. This aspect is one of the primary requirement while designing test framework. Cypress helps us the abilities to separate the test data with Cypress Fixtures. In this topic, we will be discussing about Cypress fixtures with hands-on implementation…
Table of Contents What is Cypress Commands? UI Interaction commands provided by CypressCypress Right Click CommandCypress Double Click CommandCypress Click CommandCypress Trigger CommandCypress Type CommandCypress Select CommandCypress Check CommandCypress Clear CommandAre Cypress Commands asynchronous?Cypress Custom CommandsChaining Assertion commands in CypressOverwriting existing Cypress commandsCypress Chainable CommandsParent Custom Command in CypressChild Custom Command in CypressDual Custom Command…
Page Object Model, commonly known as POM, is a popular pattern in any automation framework. Page Object Model can be applied in Cypress too. Page Object Model has many advantages in creating a framework for test automation, such as reducing code duplication and increasing maintainability and readability. Cypress provides us the flexibility to incorporate Page…
In our previous article, we saw the configurations in Cypress and various options that can be configured in JSON files. This article will understand Cypress Promise and Cypress Asynchronous behaviour with hands-on implementation and examples in our project. We will also discuss how to incorporate awaits in our asynchronous code and some essential functions like wrap()…
We will discuss the JSON structure, examples, and detailed hands-on experience to write JSON in our code. But, first, let’s dive into our article! What is Cypress Json: Example, Schema, Detailed Hands-On Analysis In our previous article, we discussed variables and aliases and how to write our first test case. Now, we will discuss Cypress JSON…
In the last article, we saw what Cypress is, its architecture, the installation process, and the pre-requisites required for the installation. However, before we begin writing our tests, we need to install Cypress. Click here to get the detailed steps to install Cypress. Cypress Example This article will discuss the Cypress example, JSON examples, variables and aliases,…