Latest Web Stories

1

Exploring Smartphone Influence on the Brain: Neurological Perspectives

2

Angular vs. React: Which One Should You Choose?

3

Discover Serenity: Your Guide to Mindfulness Apps

4

Discover how smartphone apps can enhance your mindfulness practice: 5 Senses Exercise with Apps

5

Discover How Smartwatches Measure Blood Pressure: Explained Simply

6

13 Exciting Games Launching in April 2024: From Freedom Planet 2 to TopSpin 2K25!

7

Discover the 5 Amazon Big Spring Deals on Tablets from Samsung, Lenovo

8

Big Savings Alert: Amazfit Smart Watches Now on Sale on Amazon!

9

Amazon's Big Spring Sale: Top 6 Anker Souncore Headphones and Earbuds Deals

10

Affordable VR Adventures: The Best Budget VR Headsets

11

Fly in Peace: Discover the Ultimate Noise-Cancelling Headphones for Flying

12

Bringing AI to Life: NVIDIA's Digital Human Technolgies in Healthcare, Gaming, and More

13

Discover Exciting New Games on NVIDIA GeForce NOW!

14

Steam Spring Sale 2024 is here: Explore the 10 Best FPS Games

15

The Future of iPhones: Apple's Bold Step into AI with DarwinAI

16

Discover the Magic of Sonos Soundbar: Transform Your Home Entertainment Experience!

17

Enhance Your Home Fun: 5 Best Sonos Soundbars to Amp Up Your Entertainment!

18

Pinterest Introduces AI-Powered Body Type Ranges for Inclusive Searches

19

Embrace the Next Wave: 35+ AI Tools for Enhanced Productivity in 2024

20

Xbox Gaming Bonanza: Lots of New Games with Xbox Game Pass!

21

Sony Paves the Way for Gaming Evolution with 'Super-Fungible Tokens' Patent

22

Smart Printing Choices: 10 Key Factors to Consider When Buying an HP Printer or Any Printer

23

Projector Picks: Explore the Best Mini Projectors for Big Screen Fun!

24

JavaScript Essentials: Your Quick Start to Web Coding

25

Gaming Laptop Guide 2024: 10 Crucial Checks Before You Buy + Top 5 Picks for you!

26

Gaming Joy Awaits: Explore the Best PS5 Games of 2024

27

Epic Games Special: Dive into Astro Duel 2 for FREE this week. See What’s Coming Next Week!

28

Fitbit Fitness Tracker Guide 2024: Choose Your Perfect Fit

29

Feel the Beat: Exploring Top Over-Ear Headphones

30

Explore the Web Development Strategies in 2024: A Developers Handbook

31

Explore Must-Play Nintendo Switch Games in 2024!

32

Eclipse Ready: CE and ISO Certified Solar Eclipse Glasses for a Safe Sky Spectacle

33

Disney and Pixar’s Inside Out 2 Introduces New Emotions to Riley's World

34

Discover Waze's cool new features for safer and happier drives!

35

Discover the Top Picks: Best Smartwatches for Your Lifestyle

36

Discover the Best Smartphones Trending Now: Your Easy Guide to the Best Picks!

37

Sound Revolution: Discover the Best Bluetooth Speakers of 2024!

38

Discover the 10 Best Productivity Apps to Supercharge Your Daily Tasks

39

Discover,Install and Enjoy: The Best Chrome Extensions for Developers in 2024

40

Crack the Code: Your Guide to Computer Programming Magic in 2024

41

Boost Your Content Creation: 10 ChatGPT Prompts to Supercharge Content Creation Productivity

42

10 Best Tech Companies in Silicon Valley

43

Top 10 Web Development Interview Questions you can...

44

Learn how to Answer Tell me about Yourself

45

5 Books You Need to Read Right Now

46

25 Practical Ways to Earn Money Online

Translate this page in your preferred language:


Last minute notes on Data Structures | GATE Preparation | All In One

Article by: Manish Methani

Last Updated: October 3, 2021 at 2:04pm IST

In this article, you will find the last-minute notes of Data Structures useful in the preparation of the GATE CSE exam.
Easy to remember Short formulas used for solving the problems is the bonus for you.

Arrays 

An array is a data structure used to store values of the same type.

Syntax:

Array declaration by specifying its size

int arr[10];
 

Initialise elements in an array
int arr[] = {2,4,6,7};

Specify size and initialise elements
int arr[5] = {2,4,6,8,10};

Formula:

Length of Array = UB - LB + 1

How to find the address of any element with the given address of the first element in an array,

Formula:

Loc (arr [i]) = base (arr) + size * i
size = size is the number of bytes required to store a single element of the array arr.

i = index of an array whose address we want to calculate

 

Elements of two-dimensional arrays (m X n) are stored in two ways:

Column Major order Storage

Column major order: If an array is declared by a[m][n] where m is the number of rows while n is the number of columns, then the address of an element a[i][j] of the array stored in column-major order is calculated as,

The formula is:

LOC (arr [i, j]) = Base Address + [(i - Lr) + nr(j - Lc)]*datatype size

Here,

LOC (arr [i,j]): is the location of the element in the ith row and jth column.

Base (arr): is the base address of the array arr.

nc => number of columns in the main array.

nr => number of rows in the main array.

Lr => Lower bound of base array row.

Lc => Lower bound of base array column.

Row Major order Storage

Row major order: If the array is declared by a[m][n] where m is the number of rows while n is the number of columns, then the address of an element a[i][j] of the array stored in row-major order is calculated as,

LOC (arr [i, j]) = Base Address + [nc(i - Lr) + (j - Lc)]*datatype size

Here,

LOC (arr [i,j]): is the location of the element in the ith row and jth column.

Base (arr): is the base address of the array arr.

nc => number of columns in the main array.

nr => number of rows in the main array.

Lr => Lower bound of base array row.

Lc => Lower bound of base array column.

 

Stack

Stack is a linear data structure in which operations are performed in two ways.

1) LIFO (Last In First Out)

2) FILO (fIRST INLAST OUT) 

Basic operations :

  1. Push: push() function is used to insert new elements into the Stack and pop() function is used to remove an element from the stack. Both insertion and removal are allowed at only one end of Stack called Top.
  2. Stack is said to be in an Overflow state when it is full and is said to be in an Underflow state if it is empty.

 

Infix, prefix, Postfix notations

Infix notation: + Y Operators are written in-between their operands. This is the usual way we write expressions. An expression such as

A * ( B + C ) / D

Postfix notation (also known as “Reverse Polish notation”): X Y Operators are written after their operands. The infix expression given above is equivalent to

A B C + * D/

Prefix notation (also known as “Polish notation”): + X Y Operators are written before their operands. The expressions given above are equivalent to

/ * A + B C D

Tower of Hanoi

1. It is a classic problem where you try to move all the disks from one peg to another peg using only three pegs.

2. Only one disk will be shifted at a time.

3.Smaller disk can be placed on the larger disk.

The time complexity to find the order of moves of discs in the Tower of Hanoi problem is O(2^n).

Queue

A queue is a linear structure in which the first element is inserted from one end called the REAR(also called the tail), and the removal of the existing element takes place from the other end called FRONT(also called the head).

 The order which queue follows is First In First Out (FIFO).

Enqueue: Adds an item to the queue. 

Algorithm for ENQUEUE operation

  1. Check if the queue is full or not.
  2. If the queue is full, then print the overflow error and exit the program.
  3. If the queue is not full, then increment the tail and add the element.

Dequeue: Removes an item from the queue.

Algorithm for DEQUEUE operation

  1. Check if the queue is empty or not.
  2. If the queue is empty, then print underflow error and exit the program.
  3. If the queue is not empty, then print the element at the head and increment the head.

 

Linked List

The linked list is a linear data Structure used to store elements dynamically. No need to know the actual size. In the case of arrays, you must know the size of an array. Linked List in Data Structure gives better advantages than arrays.

ArrayList vs Linked List

The difference between Array and the Linked list is explained here by the advantages of Linked List over Arrays.

1) Dynamic size 

2) Insertion/Deletion is easy in Linked List.

 

Drawbacks:

1) Random access is not allowed. We have to access elements sequentially starting from the first node. So we cannot do a binary search with linked lists.

2) Extra memory space for a pointer is required with each element of the list.

Representation in C: A linked list is represented by a pointer to the first node of the linked list. The first node is called the head. If the linked list is empty, then the value of the head is NULL.

Test your skills with these expert-led curated
Mock Tests.

C Programming Test

Test your C Programming skills with this comprehensive mock test on C Programming.

Take Test

Flutter Test

Solve most asked Interview Questions on Flutter and Test your foundational skills in flutter.

Take Test

GATE(CSE) Operating Systems

Solve most asked GATE Questions in Operating Systems and test your Gate Score.

Take Test

HTML,CSS Test

This is a mock test designed to help you assess your knowledge and skills in HTML and CSS.

Take Test

(GATE CSE) Data Structures & Algorithms Test

Solve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.

Take Test

Download the Codzify
Mobile App


Learn Anytime, Anywhere at your own pace. Scan the QR Code with your Mobile Camera to Download the Codzify Mobile App.

Codzify Mobile App Codzify Mobile App