
Domains
Agile Management
Master Agile methodologies for efficient and timely project delivery.
View All Agile Management Coursesicon-refresh-cwCertifications
Scrum Alliance
16 Hours
Best Seller
Certified ScrumMaster (CSM) CertificationScrum Alliance
16 Hours
Best Seller
Certified Scrum Product Owner (CSPO) CertificationScaled Agile
16 Hours
Trending
Leading SAFe 6.0 CertificationScrum.org
16 Hours
Professional Scrum Master (PSM) CertificationScaled Agile
16 Hours
SAFe 6.0 Scrum Master (SSM) CertificationAdvanced Certifications
Scaled Agile, Inc.
32 Hours
Recommended
Implementing SAFe 6.0 (SPC) CertificationScaled Agile, Inc.
24 Hours
SAFe 6.0 Release Train Engineer (RTE) CertificationScaled Agile, Inc.
16 Hours
Trending
SAFe® 6.0 Product Owner/Product Manager (POPM)IC Agile
24 Hours
ICP Agile Certified Coaching (ICP-ACC)Scrum.org
16 Hours
Professional Scrum Product Owner I (PSPO I) TrainingMasters
32 Hours
Trending
Agile Management Master's Program32 Hours
Agile Excellence Master's ProgramOn-Demand Courses
Agile and ScrumRoles
Scrum MasterTech Courses and Bootcamps
Full Stack Developer BootcampAccreditation Bodies
Scrum AllianceTop Resources
Scrum TutorialProject Management
Gain expert skills to lead projects to success and timely completion.
View All Project Management Coursesicon-standCertifications
PMI
36 Hours
Best Seller
Project Management Professional (PMP) CertificationAxelos
32 Hours
PRINCE2 Foundation & Practitioner CertificationAxelos
16 Hours
PRINCE2 Foundation CertificationAxelos
16 Hours
PRINCE2 Practitioner CertificationSkills
Change ManagementMasters
Job Oriented
45 Hours
Trending
Project Management Master's ProgramUniversity Programs
45 Hours
Trending
Project Management Master's ProgramOn-Demand Courses
PRINCE2 Practitioner CourseRoles
Project ManagerAccreditation Bodies
PMITop Resources
Theories of MotivationCloud Computing
Learn to harness the cloud to deliver computing resources efficiently.
View All Cloud Computing Coursesicon-cloud-snowingCertifications
AWS
32 Hours
Best Seller
AWS Certified Solutions Architect - AssociateAWS
32 Hours
AWS Cloud Practitioner CertificationAWS
24 Hours
AWS DevOps CertificationMicrosoft
16 Hours
Azure Fundamentals CertificationMicrosoft
24 Hours
Best Seller
Azure Administrator CertificationMicrosoft
45 Hours
Recommended
Azure Data Engineer CertificationMicrosoft
32 Hours
Azure Solution Architect CertificationMicrosoft
40 Hours
Azure DevOps CertificationAWS
24 Hours
Systems Operations on AWS Certification TrainingAWS
24 Hours
Developing on AWSMasters
Job Oriented
48 Hours
New
AWS Cloud Architect Masters ProgramBootcamps
Career Kickstarter
100 Hours
Trending
Cloud Engineer BootcampRoles
Cloud EngineerOn-Demand Courses
AWS Certified Developer Associate - Complete GuideAuthorized Partners of
AWSTop Resources
Scrum TutorialIT Service Management
Understand how to plan, design, and optimize IT services efficiently.
View All DevOps Coursesicon-git-commitCertifications
Axelos
16 Hours
Best Seller
ITIL 4 Foundation CertificationAxelos
16 Hours
ITIL Practitioner CertificationPeopleCert
16 Hours
ISO 14001 Foundation CertificationPeopleCert
16 Hours
ISO 20000 CertificationPeopleCert
24 Hours
ISO 27000 Foundation CertificationAxelos
24 Hours
ITIL 4 Specialist: Create, Deliver and Support TrainingAxelos
24 Hours
ITIL 4 Specialist: Drive Stakeholder Value TrainingAxelos
16 Hours
ITIL 4 Strategist Direct, Plan and Improve TrainingOn-Demand Courses
ITIL 4 Specialist: Create, Deliver and Support ExamTop Resources
ITIL Practice TestData Science
Unlock valuable insights from data with advanced analytics.
View All Data Science Coursesicon-dataBootcamps
Job Oriented
6 Months
Trending
Data Science BootcampJob Oriented
289 Hours
Data Engineer BootcampJob Oriented
6 Months
Data Analyst BootcampJob Oriented
288 Hours
New
AI Engineer BootcampSkills
Data Science with PythonRoles
Data ScientistOn-Demand Courses
Data Analysis Using ExcelTop Resources
Machine Learning TutorialDevOps
Automate and streamline the delivery of products and services.
View All DevOps Coursesicon-terminal-squareCertifications
DevOps Institute
16 Hours
Best Seller
DevOps Foundation CertificationCNCF
32 Hours
New
Certified Kubernetes AdministratorDevops Institute
16 Hours
Devops LeaderSkills
KubernetesRoles
DevOps EngineerOn-Demand Courses
CI/CD with Jenkins XGlobal Accreditations
DevOps InstituteTop Resources
Top DevOps ProjectsBI And Visualization
Understand how to transform data into actionable, measurable insights.
View All BI And Visualization Coursesicon-microscopeBI and Visualization Tools
Certification
24 Hours
Recommended
Tableau CertificationCertification
24 Hours
Data Visualization with Tableau CertificationMicrosoft
24 Hours
Best Seller
Microsoft Power BI CertificationTIBCO
36 Hours
TIBCO Spotfire TrainingCertification
30 Hours
Data Visualization with QlikView CertificationCertification
16 Hours
Sisense BI CertificationOn-Demand Courses
Data Visualization Using Tableau TrainingTop Resources
Python Data Viz LibsCyber Security
Understand how to protect data and systems from threats or disasters.
View All Cyber Security Coursesicon-refresh-cwCertifications
CompTIA
40 Hours
Best Seller
CompTIA Security+EC-Council
40 Hours
Certified Ethical Hacker (CEH v12) CertificationISACA
22 Hours
Certified Information Systems Auditor (CISA) CertificationISACA
40 Hours
Certified Information Security Manager (CISM) Certification(ISC)²
40 Hours
Certified Information Systems Security Professional (CISSP)(ISC)²
40 Hours
Certified Cloud Security Professional (CCSP) Certification16 Hours
Certified Information Privacy Professional - Europe (CIPP-E) CertificationISACA
16 Hours
COBIT5 Foundation16 Hours
Payment Card Industry Security Standards (PCI-DSS) CertificationOn-Demand Courses
CISSPTop Resources
Laptops for IT SecurityWeb Development
Learn to create user-friendly, fast, and dynamic web applications.
View All Web Development Coursesicon-codeBootcamps
Career Kickstarter
6 Months
Best Seller
Full-Stack Developer BootcampJob Oriented
3 Months
Best Seller
UI/UX Design BootcampEnterprise Recommended
6 Months
Java Full Stack Developer BootcampCareer Kickstarter
490+ Hours
Front-End Development BootcampCareer Accelerator
4 Months
Backend Development Bootcamp (Node JS)Skills
ReactOn-Demand Courses
Angular TrainingTop Resources
Top HTML ProjectsBlockchain
Understand how transactions and databases work in blockchain technology.
View All Blockchain Coursesicon-stop-squareBlockchain Certifications
40 Hours
Blockchain Professional Certification32 Hours
Blockchain Solutions Architect Certification32 Hours
Blockchain Security Engineer Certification24 Hours
Blockchain Quality Engineer Certification5+ Hours
Blockchain 101 CertificationOn-Demand Courses
NFT Essentials 101: A Beginner's GuideTop Resources
Blockchain Interview QsProgramming
Learn to code efficiently and design software that solves problems.
View All Programming Coursesicon-codeSkills
Python CertificationInterview Prep
Career Accelerator
3 Months
Software Engineer Interview PrepOn-Demand Courses
Data Structures and Algorithms with JavaScriptTop Resources
Python TutorialProgramming
4.7 Rating 50 Questions 25 mins read18 Readers

In computer systems, a data structure is a method that helps to store and efficiently retrieve data. Data can take many different forms, and to store and retrieve it effectively, we must have a solid grasp of data structures. Data structures come in a variety of formats, and we must choose the best one for the task at hand. For instance, you would utilise the appropriate data structure type if you needed to store data that was ordered or unordered, had a fixed length or variable length, or both. Some of the most common data structures used by programmers are:
Programmers are responsible for solving logical problems through critical thinking. They are not required to know any programming language or syntax. Their responsibility is to prepare the algorithm or even the pseudo-code. On the other hand, coders are responsible to write the logic or algorithm in a specific programming language. They can understand the syntaxes, optimize the code, debug and run test cases, and use different libraries and modules. You can consider that defining an algorithm for a data structure is the task of a programmer while implementing the data structure in a specific programming language like Java, C++, Python, etc. is the task of the coder. It is generally preferred that a coder should be a good programmer.
Arrays are the simplest data structures. Almost all the programming languages have an in-built implementation of an array (it might come with slight modification). An array can be understood as a box of cookies placed in a single row one after the other. Each cookie is an element or item. Each cookie in the box is next to the other just like elements in an array. Each cookie can be identified with a unique location and so the items are in an array. However, the position of the items in an array starts with index 0 followed by 1, 2, 3, and so on. The size of the array is fixed just like the cookie box. You cannot add more cookies once the box is full. Therefore, arrays have static memory allocation but however one can also implement a dynamic array as per the usage. A cookie box will only contain cookies and not cake or another item. Similarly, an array contains a single data type i.e., it is homogeneous. However, we can also have heterogeneous array types as well. For example, python lists mimic an array data structure but come with variable length and the ability to store a variety of data types making it heterogeneous. The below image demonstrates an array of lengths equal to 10 and therefore, the index position ranges from 0 to 9.

LIFO stands for Last In First Out. The idea follows from the stack of items. For example, a stack of books is placed on a table. Considering you want to add a new book to the stack, the ideal way will be to place the book on top of the stack. Now, to access the stack you have to first remove the top-most book which is nothing but the most recent addition to the stack. Hence, the stack follows the last in first out order. Stack is a widely used data structure that provides a way of accessing, storing and retrieving data.

The FIFO or First In First Out order comes from the idea of queues. A queue of people standing in line means that the person at the start of the line will be the first one to leave the queue. There are a lot of real-life examples of queues like the queue during the security check in an airport. Similarly, in a queue data structure, the data that is stored first is retrieved first. This is in contrast to a stack where the first item is the last to leave the stack during retrieval.

The bubble sort is the simplest way of sorting which is sometimes called sinking sort. In a bubble sort, we repeatedly compare each pair of adjacent elements and swap them if they are in the wrong order. We repeat this process until all elements get sorted. Let us use an example to understand this example clearly. Consider the following array.

We will compare the first two elements in the array, i.e., 56 (index 0) and 63 (index 1). If the left element (at a lesser index) is greater than the right element (at a greater index), we will swap the numbers otherwise ignore them. So, in the first comparison between 56 and 63, we ignore them. During the second comparison, we compare 63 (index 1) and 84 (index 2). Again, the element at the lower index, that is, 63 is smaller than the element at the higher index, 84, so we ignore them. During the comparison of 22 (index 2) and 84 (index 3), we notice that the element at index 2 is greater than the element at index 3 so we swap the two numbers. The below image represents the complete first iteration during the bubble sorting of the above array. The coloured elements are the ones which are taken into consideration during the comparison. The elements coloured in light blue represent that the items are not swapped after comparison. The elements coloured in orange represent that the element was swapped after comparison. Finally, we get an array in which the last item (84 coloured in red) is frozen and it won’t be considered for any further sorting operation.
Now, during the second set of iterations, the second highest number will get sorted. During each successive iteration, it will not consider the frozen elements from previous iterations. The further iterations for the sorting are –
The pseudocode to implement a bubble sort algorithm is –
input_arr = [56, 63, 84, 22, 71, 49] arr_length = len(input_arr) for i in range(0, arr_length – 1): for j in range(0, arr_length – i – 1): if input_arr[j] > input_arr[j+1]: temp = input_arr[j] input_arr[j] = input_arr[j+1] input_arr[j+1] = temp print(‘Sorted Array:’, input_arr)
The output of the above program is “Sorted Array: [22, 49, 56, 63, 71, 84]”.
A stack data structure can be imagined as a pile of objects stacked vertically. When we make an addition to the stack, it is added to the top and while accessing the stack, the last added object to the stack is the first to be accessed. The common stack operations are:
The stack can be implemented in python using the code –
class Stack:
# Initialize the stack with the provided length
def __init__(self, length):
self.stack = []
self.length = length
self.__size = 0
def size(self):
'''
Returns the current size of the stack
'''
return self.__size
def isEmpty(self):
'''
Returns True if the stack is empty, else False
'''
return self.__size == 0
def isFull(self):
'''
Returns True if the stack is full, else False
'''
return self.length == self.__size
def push(self, element):
'''
Adds a new element to the stack if there is a space.
'''
if not self.isFull():
self.stack.append(element)
self.__size += 1
print(f'Successfully added {element} to the stack.')
else:
print('Stack is full. New element cannot be added to the stack.')
def pop(self):
'''
Removes and returns the value of an element present at top of the stack, if the stack is not empty.
'''
if not self.isEmpty():
element = self.stack.pop(-1)
self.__size -= 1
print('Successfully removed element from top of the stack.')
return element
print('Stack is empty. Nothing to pop from the stack.')
def peek(self):
'''
Returns the value of the element present at the top of the stack if the stack is not empty.
'''
if not self.isEmpty():
return self.stack[-1]
print('Stack is empty. Nothing to peek in the stack.')
def delete(self):
'''
Deletes the stack
'''
self.stack = None
# Create a new stack with length = 5
s = Stack(length = 5)
# Pop item from the stack
print(s.pop())
# Check if the stack is empty
print(s.isEmpty())
# Peek item from the stack
print(s.peek())
# Push 3 items to the stack
s.push(30)
s.push(40)
s.push(55)
# Check the size of the stack
print(s.size())
# Push two more elements to the stack
s.push(60)
s.push(85)
# Peek in the stack and print the response
print(s.peek())
# Add one more item to the stack
s.push(100)
# Check if the stack is full
print(s.isFull())
# Pop an item from the stack
print(s.pop()) The output of the program is –
Stack is empty. Nothing to pop from the stack. None True Stack is empty. Nothing to peek in the stack. None Successfully added 30 to the stack. Successfully added 40 to the stack. Successfully added 55 to the stack. 3 Successfully added 60 to the stack. Successfully added 85 to the stack. 85 Stack is full. New element cannot be added to the stack. True Successfully removed element from top of the stack. 85
A queue is a data structure that stores items in a first-in-first-out (FIFO) order just like a queue of persons standing. The common queue operations are:
The queue can be implemented in python using the code –
class Queue:
# Initialize the queue with the provided length
def __init__(self, length):
self.queue = []
self.length = length
self.__size = 0
def size(self):
'''
Returns the current size of the queue
'''
return self.__size
def isEmpty(self):
'''
Returns True if the queue is empty, else False
'''
return self.__size == 0
def isFull(self):
'''
Returns True if the queue is full, else False
'''
return self.length == self.__size
def enqueue(self, element):
'''
Adds a new element to the queue if there is a space.
'''
if not self.isFull():
self.queue.append(element)
self.__size += 1
print(f'Successfully added {element} to the queue.')
else:
print('Queue is full. New element cannot be placed in the queue.')
def dequeue(self):
'''
Removes and returns the value of an element present in the front of the queue, if the queue is not empty.
'''
if not self.isEmpty():
element = self.queue.pop(0)
self.__size -= 1
print('Successfully removed element from front of the queue.')
return element
print('Queue is empty. Nothing to dequeue.')
def peek(self):
'''
Returns the value of the element present in the front of the queue if the queue is not empty.
'''
if not self.isEmpty():
return self.queue[0]
print('Queue is empty. Nothing to peek in the queue.')
def delete(self):
'''
Deletes the stack
'''
self.queue = None
print('Queue deleted successfully.')
# Create a new queue with length = 5
q = Queue(length = 5)
# dequeue an item from the queue
print(q.dequeue())
# Check if the queue is empty
print(q.isEmpty())
# Peek item from the front of the queue
print(q.peek())
# Enqueue 3 items to the queue
q.enqueue(30)
q.enqueue(40)
q.enqueue(55)
# Check the size of the queue
print(q.size())
# Enqueue two more elements to the queue
q.enqueue(60)
q.enqueue(85)
# Peek in the front of the queue and print the response
print(q.peek())
# Equeue one more item to the queue
q.enqueue(100)
# Check if the queue is full
print(q.isFull())
# Enqueue an item from the queue
print(q.dequeue())
# Delete the queue
q.delete() The output of the program is –
Queue is empty. Nothing to dequeue. None True Queue is empty. Nothing to peek in the queue. None Successfully added 30 to the queue. Successfully added 40 to the queue. Successfully added 55 to the queue. 3 Successfully added 60 to the queue. Successfully added 85 to the queue. 30 Queue is full. New element cannot be placed in the queue. True Successfully removed element from front of the queue. 30 Queue deleted successfully.
An anagram is a word or phrase that is created by rearranging the letters of another word or phrase, usually utilizing every letter exactly once. Examples include rearranging the words care to become race, binary to become brainy, and heart to become earth. To prove whether two strings are anagrams or not, we can perform sorting on both strings and if the sorted strings match each other then we can consider the strings to be anagrams of each other. The pseudocode can be given as –
The python program for this is given as –
string_1 = 'care'
string_2 = 'race'
len_str1 = len(string_1)
len_str2 = len(string_2)
anagram_flag = True
if len_str1 != len_str2:
anagram_flag = False
else:
string_1 = ''.join(sorted(string_1))
string_2 = ''.join(sorted(string_2))
for idx in range(0, len_str1):
if string_1[idx] != string_2[idx]:
anagram_flag = False
if anagram_flag:
print('The strings are anagrams')
else:
print('The strings are not anagrams')