514 Part B
514 Part B
Software development Life Cycle (SDLC) is a methodology for a software product. It is improving the quality of
software and the overall development process.
Software development Life Cycle (SDLC) refers to all the phases of a software product throughout its
planning, development, and use, all the way through to its eventual obsolescence or retirement. This process
has many variable parts, but it can often be segmented into several main pieces. This helps developers and
others to understand how a product is created, implemented and used.
Several of the most common parts of a software life cycle are planning phases. Typically referred to as
requirements gathering or analysis, where an undeveloped product is defined through gathered criteria.
Subsequent phases involve the analysis and design of the product, followed by development. The last parts
of the life cycle involve a product that has been released to a customer or other end user, at which time the
product maker often continues to be involved through maintenance, problem solving, upgrading and other
processes.
Business analyst and Project organizer set up a meeting with the client to gather all the data like what the
customer wants to build, who will be the end user, what is the objective of the product. Before creating a
product, a core understanding or knowledge of the product is very necessary.
For Example, A client wants to have an application which concerns money transactions. In this method, the
requirement has to be precise like what kind of operations will be done, how it will be done, in which currency
it will be done, etc.
Once the required function is done, an analysis is complete with auditing the feasibility of the growth of a
product. In case of any ambiguity, a signal is set up for further discussion.
Once the requirement is understood, the SRS (Software Requirement Specification) document is created. The
developers should thoroughly follow this document and also should be reviewed by the customer for future
reference.
Without using an exact life cycle model, the development of a software product would not be in a systematic
and disciplined manner. When a team is developing a software product, there must be a clear understanding
among team representative about when and what to do. Otherwise, it would point to chaos and project
failure. This problem can be defined by using an example. Suppose a software development issue is divided
into various parts and the parts are assigned to the team members. From then on, suppose the team
representative is allowed the freedom to develop the roles assigned to them in whatever way they like. It is
possible that one representative might start writing the code for his part, another might choose to prepare
the test documents first, and some other engineer might begin with the design phase of the roles assigned to
him. This would be one of the perfect methods for project failure.
A software life cycle model describes entry and exit criteria for each phase. A phase can begin only if its stage-
entry criteria have been fulfilled. So without a software life cycle model, the entry and exit criteria for a stage
cannot be recognized. Without software life cycle models, it becomes tough for software project managers to
monitor the progress of the project.
What are SDLC models?
A software development lifecycle (SDLC) model conceptually presents SDLC in an organized fashion to help
organizations implement it. Different models arrange the SDLC phases in varying chronological order to
optimize the development cycle. We look at some popular SDLC models below.
Waterfall
The waterfall model arranges all the phases sequentially so that each new phase depends on the outcome of
the previous phase. Conceptually, the design flows from one phase down to the next, like that of a waterfall.
The waterfall model provides discipline to project management and gives a tangible output at the end of
each phase. However, there is little room for change once a phase is considered complete, as changes can
affect the software's delivery time, cost, and quality. Therefore, the model is most suitable for small
software development projects, where tasks are easy to arrange and manage and requirements can be pre-
defined accurately.
Iterative
The iterative process suggests that teams begin software development with a small subset of requirements.
Then, they iteratively enhance versions over time until the complete software is ready for production. The
team produces a new software version at the end of each iteration.
It’s easy to identify and manage risks, as requirements can change between iterations. However, repeated
cycles could lead to scope change and underestimation of resources.
Spiral
The spiral model combines the iterative model's small repeated cycles with the waterfall model's linear
sequential flow to prioritize risk analysis. You can use the spiral model to ensure software's gradual release
and improvement by building prototypes at each phase.
The spiral model is suitable for large and complex projects that require frequent changes. However, it can be
expensive for smaller projects with a limited scope.
Agile
The agile model arranges the SDLC phases into several development cycles. The team iterates through the
phases rapidly, delivering only small, incremental software changes in each cycle. They continuously
evaluate requirements, plans, and results so that they can respond quickly to change. The agile model is
both iterative and incremental, making it more efficient than other process models.
Rapid development cycles help teams identify and address issues in complex projects early on and before
they become significant problems. They can also engage customers and stakeholders to obtain feedback
throughout the project lifecycle. However, overreliance on customer feedback could lead to excessive scope
changes or end the project midway.
SDLC - WATERFALL MODEL
The Waterfall Model was the first Process Model to be introduced. It is also referred to as a linear-sequential
life cycle model. It is very simple to understand and use. In a waterfall model, each phase must be completed
before the next phase can begin and there is no overlapping in the phases.
The Waterfall model is the earliest SDLC approach that was used for software development.
The waterfall Model illustrates the software development process in a linear sequential flow. This means that
any phase in the development process begins only if the previous phase is complete. In this waterfall model,
the phases do not overlap.
Waterfall Model - Design
Waterfall approach was first SDLC Model to be used widely in Software Engineering to ensure success of the
project. In "The Waterfall" approach, the whole process of software development is divided into separate
phases. In this Waterfall model, typically, the outcome of one phase acts as the input for the next phase
sequentially.
The following illustration is a representation of the different phases of the Waterfall Model.
Iterative and Incremental development is a combination of both iterative design or iterative method and
incremental build model for development. "During software development, more than one iteration of the
software development cycle may be in progress at the same time." This process may be described as an
"evolutionary acquisition" or "incremental build" approach."
In this incremental model, the whole requirement is divided into various builds. During each iteration, the
development module goes through the requirements, design, implementation and testing phases. Each
subsequent release of the module adds function to the previous release. The process continues till the
complete system is ready as per the requirement.
The key to a successful use of an iterative software development lifecycle is rigorous validation of
requirements, and verification & testing of each version of the software against those requirements within
each cycle of the model. As the software evolves through successive cycles, tests must be repeated and
extended to verify each version of the software.
Iterative Model - Application
Like other SDLC models, Iterative and incremental development has some specific applications in the software
industry. This model is most often used in the following scenarios −
Requirements of the complete system are clearly defined and understood.
Major requirements must be defined; however, some functionalities or requested enhancements may
evolve with time.
There is a time to the market constraint.
A new technology is being used and is being learnt by the development team while working on the
project.
Resources with needed skill sets are not available and are planned to be used on contract basis for
specific iterations.
There are some high-risk features and goals which may change in the future.
There are several Verification phases in the V-Model, each of these are explained in detail below.
Business Requirement Analysis
This is the first phase in the development cycle where the product requirements are understood from the
customer’s perspective. This phase involves detailed communication with the customer to understand his
expectations and exact requirement. This is a very important activity and needs to be managed well, as most
of the customers are not sure about what exactly they need. The acceptance test design planning is done at
this stage as business requirements can be used as an input for acceptance testing.
System Design
Once you have the clear and detailed product requirements, it is time to design the complete system. The
system design will have the understanding and detailing the complete hardware and communication setup for
the product under development. The system test plan is developed based on the system design. Doing this at
an earlier stage leaves more time for the actual test execution later.
Architectural Design
Architectural specifications are understood and designed in this phase. Usually more than one technical
approach is proposed and based on the technical and financial feasibility the final decision is taken. The system
design is broken down further into modules taking up different functionality. This is also referred to as High
Level Design (HLD).
The data transfer and communication between the internal modules and with the outside world (other
systems) is clearly understood and defined in this stage. With this information, integration tests can be
designed and documented during this stage.
Module Design
In this phase, the detailed internal design for all the system modules is specified, referred to as Low Level
Design (LLD). It is important that the design is compatible with the other modules in the system architecture
and the other external systems. The unit tests are an essential part of any development process and helps
eliminate the maximum faults and errors at a very early stage. These unit tests can be designed at this stage
based on the internal module designs.
Coding Phase
The actual coding of the system modules designed in the design phase is taken up in the Coding phase. The
best suitable programming language is decided based on the system and architectural requirements.
The coding is performed based on the coding guidelines and standards. The code goes through numerous code
reviews and is optimized for best performance before the final build is checked into the repository.
Validation Phases
The different Validation Phases in a V-Model are explained in detail below.
Unit Testing
Unit tests designed in the module design phase are executed on the code during this validation phase. Unit
testing is the testing at code level and helps eliminate bugs at an early stage, though all defects cannot be
uncovered by unit testing.
Integration Testing
Integration testing is associated with the architectural design phase. Integration tests are performed to test
the coexistence and communication of the internal modules within the system.
System Testing
System testing is directly associated with the system design phase. System tests check the entire system
functionality and the communication of the system under development with external systems. Most of the
software and hardware compatibility issues can be uncovered during this system test execution.
Acceptance Testing
Acceptance testing is associated with the business requirement analysis phase and involves testing the
product in user environment. Acceptance tests uncover the compatibility issues with the other systems
available in the user environment. It also discovers the non-functional issues such as load and performance
defects in the actual user environment.
V- Model ─ Application
V- Model application is almost the same as the waterfall model, as both the models are of sequential type.
Requirements have to be very clear before the project starts, because it is usually expensive to go back and
make changes. This model is used in the medical development field, as it is strictly a disciplined domain.
The following pointers are some of the most suitable scenarios to use the V-Model application.
Requirements are well defined, clearly documented and fixed.
Product definition is stable.
Technology is not dynamic and is well understood by the project team.
There are no ambiguous or undefined requirements.
The project is short.
V-Model - Pros and Cons
The advantage of the V-Model method is that it is very easy to understand and apply. The simplicity of this
model also makes it easier to manage. The disadvantage is that the model is not flexible to changes and just
in case there is a requirement change, which is very common in today’s dynamic world, it becomes very
expensive to make the change.
The advantages of the V-Model method are as follows −
This is a highly-disciplined model and Phases are completed one at a time.
Works well for smaller projects where requirements are very well understood.
Simple and easy to understand and use.
Easy to manage due to the rigidity of the model. Each phase has specific deliverables and a review
process.
The disadvantages of the V-Model method are as follows −
High risk and uncertainty.
Not a good model for complex and object-oriented projects.
Poor model for long and ongoing projects.
Not suitable for the projects where requirements are at a moderate to high risk of changing.
Once an application is in the testing stage, it is difficult to go back and change a functionality.
No working software is produced until late during the life cycle.
The Big Bang model is an SDLC model where we do not follow any specific process. The development just
starts with the required money and efforts as the input, and the output is the software developed which may
or may not be as per customer requirement. This Big Bang Model does not follow a process/procedure and
there is a very little planning required. Even the customer is not sure about what exactly he wants and the
requirements are implemented on the fly without much analysis.
Usually this model is followed for small projects where the development teams are very small.
Big Bang Model ─ Design and Application
The Big Bang Model comprises of focusing all the possible resources in the software development and coding,
with very little or no planning. The requirements are understood and implemented as they come. Any changes
required may or may not need to revamp the complete software.
This model is ideal for small projects with one or two developers working together and is also useful for
academic or practice projects. It is an ideal model for the product where requirements are not well understood
and the final release date is not given.
Big Bang Model - Pros and Cons
The advantage of this Big Bang Model is that it is very simple and requires very little or no planning. Easy to
manage and no formal procedure are required.
However, the Big Bang Model is a very high risk model and changes in the requirements or misunderstood
requirements may even lead to complete reversal or scraping of the project. It is ideal for repetitive or small
projects with minimum risks.
The advantages of the Big Bang Model are as follows −
This is a very simple model
Little or no planning required
Easy to manage
Very few resources required
Gives flexibility to developers
It is a good learning aid for new comers or students.
The disadvantages of the Big Bang Model are as follows −
Very High risk and uncertainty.
Not a good model for complex and object-oriented projects.
Poor model for long and ongoing projects.
Can turn out to be very expensive if requirements are misunderstood.
SOFTWARE DESIGN
Software design is a process to transform user requirements into some suitable form, which helps the
programmer in software coding and implementation.
For assessing user requirements, an SRS (Software Requirement Specification) document is created whereas
for coding and implementation, there is a need of more specific and detailed requirements in software terms.
The output of this process can directly be used into implementation in programming languages.
Software design is the first step in SDLC (Software Design Life Cycle), which moves the concentration from
problem domain to solution domain. It tries to specify how to fulfill the requirements mentioned in SRS.
Software design principles are concerned with providing means to handle the complexity of the design process
effectively. Effectively managing the complexity will not only reduce the effort needed for design but can also
reduce the scope of introducing errors during design.
For software design, the goal is to divide the problem into manageable pieces.
These pieces cannot be entirely independent of each other as they together form the system. They have to
cooperate and communicate to solve the problem. This communication adds complexity.
Data packaging and implementation, including issues of scope and
2. Abstraction
An abstraction is a tool that enables a designer to consider a component at an abstract level without bothering
about the internal details of the implementation. Abstraction can be used for existing element as well as the
component being designed.
1. Functional Abstraction
2. Data Abstraction
Functional Abstraction
i. A module is specified by the method it performs.
ii. The details of the algorithm to accomplish the functions are not visible to the user of the function.
Functional abstraction forms the basis for Function oriented design approaches.
Data Abstraction
Details of the data elements are not visible to the users of data. Data Abstraction forms the basis for Object
Oriented design approaches.
3. Modularity
Modularity specifies the division of software into separate modules which are differently named and
addressed and are integrated later on to obtain the completely functional software. It is the only property that
allows a program to be intellectually manageable. Single large programs are difficult to understand and read
due to a large number of reference variables, control paths, global variables, etc.
The desirable properties of a modular system are:
1. Each module is a well-defined system that can be used with other applications.
2. Each module has single specified objectives.
3. Modules can be separately compiled and saved in the library.
4. Modules should be easier to use than to build.
5. Modules are simpler from outside than inside.
Advantages of Modularity
Disadvantages of Modularity
Modular Design
Modular design reduces the design complexity and results in easier and faster implementation by allowing
parallel development of various parts of a system. We discuss a different section of modular design in detail
in this section:
1. Functional Independence: Functional independence is achieved by developing functions that perform only
one kind of task and do not excessively interact with other modules. Independence is important because it
makes implementation more accessible and faster. The independent modules are easier to maintain, test, and
reduce error propagation and can be reused in other programs as well. Thus, functional independence is a
good design feature which ensures software quality.
It is measured using two criteria:
Cohesion: It measures the relative function strength of a module.
Coupling: It measures the relative interdependence among modules.
2. Information hiding: The fundamental of Information hiding suggests that modules can be characterized by
the design decisions that protect from the others, i.e., In other words, modules should be specified that data
include within a module is inaccessible to other modules that do not need for such information.
The use of information hiding as design criteria for modular system provides the most significant benefits
when modifications are required during testing's and later during software maintenance. This is because as
most data and procedures are hidden from other parts of the software, inadvertent errors introduced during
modifications are less likely to propagate to different locations within the software.
Strategy of Design
A good system design strategy is to organize the program modules in such a method that are easy to develop
and latter too, change. Structured design methods help developers to deal with the size and complexity of
programs. Analysts generate instructions for the developers about how code should be composed and how
pieces of code should fit together to form a program.
1. Top-down Approach: This approach starts with the identification of the main components and then
decomposing them into their more detailed sub-components.
2. Bottom-up Approach: A bottom-up approach begins with the lower details and moves towards up the
hierarchy, as shown in fig. This approach is suitable in case of an existing system.
DATA STRUCTURES TUTORIAL
Data Structure is a way to store and organize data so that it can be used efficiently.
The data structure as the name indicates is organizing the data in memory. There are many ways of
organizing the data in the memory as we have already seen one of the data structures, i.e., array in
C language. Array is a collection of memory elements in which data is stored sequentially, i.e., one
after another. In other words, we can say that array stores the elements in a continuous manner.
This organization of data is done with the help of an array of data structures. There are also other
ways to organize the data in memory. Let's see the different types of data structures.
The data structure is not any programming language like C, C++, java, etc. It is a set of algorithms that
we can use in any programming language to structure the data in the memory.
To structure the data in memory, 'n' number of algorithms were proposed, and all these algorithms
are known as Abstract data types. These abstract data types are the set of rules.
The primitive data structures are primitive data types. The int, char, float, double, and pointer are
the primitive data structures that can hold a single value.
Major Operations
The major or the common operations that can be performed on the data structures are:
A data structure is a way of organizing the data so that it can be used efficiently. Here, we have used
the word efficiently, which in terms of both the space and time. For example, a stack is an ADT
(Abstract data type) which uses either arrays or linked list data structure for the implementation.
Therefore, we conclude that we require some data structure to implement a particular ADT.
An ADT tells what is to be done and data structure tells how it is to be done. In other words, we can
say that ADT gives us the blueprint while data structure provides the implementation part. Now the
question arises: how can one get to know which data structure to be used for a particular ADT?.
As the different data structures can be implemented in a particular ADT, but the different
implementations are compared for time and space. For example, the Stack ADT can be implemented
by both Arrays and linked list. Suppose the array is providing time efficiency while the linked list is
providing space efficiency, so the one which is the best suited for the current user's requirements
will be selected.
Advantages of Data structures
o Efficiency: If the choice of a data structure for implementing a particular ADT is proper, it
makes the program very efficient in terms of time and space.
o Reusability: The data structure provides reusability means that multiple client programs can
use the data structure.
o Abstraction: The data structure specified by an ADT also provides the level of abstraction. The
client cannot see the internal working of the data structure, so it does not have to worry about
the implementation part. The client can only see the interface.
Data Structure is a way of collecting and organising data in such a way that we can perform
operations on these data in an effective way. Data Structures is about rendering data elements in
terms of some relationship, for better organization and storage. For example, we have some data
which has, player's name "Virat" and age 26. Here "Virat" is of String data type and 26 is
of integer data type.
We can organize this data as a record like Player record, which will have both player's name and
age in it. Now we can collect and store player's records in a file or database as a data structure. For
example: "Dhoni" 30, "Gambhir" 31, "Sehwag" 33
In simple language, Data Structures are structures programmed to store ordered data, so that
various operations can be performed on it easily. It represents the knowledge of data to be
organized in memory. It should be designed and implemented in such a way that it reduces the
complexity and increases the efficiency.
Characteristic Description
In Linear data structures, the data items are arranged in a linear sequence.
Linear
Example: Array
Non- In Non-Homogeneous data structure, the elements may or may not be of the same
Homogeneous type. Example: Structures
Static data structures are those whose sizes and structures associated memory
Static
locations are fixed, at compile time. Example: Array
Dynamic structures are those which expands or shrinks depending upon the
Dynamic program need and its execution. Also, their associated memory locations changes.
Example: Linked List created using pointers
It can hold value but not data. Therefore, it It can hold multiple types of data within a single
is dataless. object.
There is no time complexity in the case of In data structure objects, time complexity plays an
data types. important role.
Data Type Data Structure
Data type examples are int, float, double, Data structure examples are stack, queue, tree,
etc. etc.
ARRAYS:
An array is a linear data structure and it is a collection of items stored at contiguous memory
locations. The idea is to store multiple items of the same type together in one place. It allows the
processing of a large amount of data in a relatively short period. The first element of the array is
indexed by a subscript of 0. There are different operations possible in an array, like Searching,
Sorting, Inserting, Traversing, Reversing, and Deleting.
Array
Characteristics of an Array:
An array has various characteristics which are as follows:
Arrays use an index-based data structure which helps to identify each of the elements in an
array easily using the index.
If a user wants to store multiple values of the same data type, then the array can be utilized
efficiently.
An array can also handle complex data structures by storing data in a two-dimensional array.
An array is also used to implement other data structures like Stacks, Queues, Heaps, Hash
tables, etc.
The search process in an array can be done very easily.
Initialization: An array can be initialized with values at the time of declaration or later using an
assignment statement.
Accessing elements: Elements in an array can be accessed by their index, which starts from 0
and goes up to the size of the array minus one.
Searching for elements: Arrays can be searched for a specific element using linear search or
binary search algorithms.
Sorting elements: Elements in an array can be sorted in ascending or descending order using
algorithms like bubble sort, insertion sort, or quick sort.
Inserting elements: Elements can be inserted into an array at a specific location, but this
operation can be time-consuming because it requires shifting existing elements in the array.
Deleting elements: Elements can be deleted from an array by shifting the elements that come
after it to fill the gap.
Updating elements: Elements in an array can be updated or modified by assigning a new value
to a specific index.
Traversing elements: The elements in an array can be traversed in order, visiting each element
once.
These are some of the most common operations performed on arrays. The specific operations and
algorithms used may vary based on the requirements of the problem and the programming
language used.
Applications of Array:
Different applications of an array are as follows:
An array is used in solving matrix problems.
Database records are also implemented by an array.
It helps in implementing a sorting algorithm.
It is also used to implement other data structures like Stacks, Queues, Heaps, Hash tables, etc.
An array can be used for CPU scheduling.
Can be applied as a lookup table in computers.
Arrays can be used in speech processing where every speech signal is an array.
The screen of the computer is also displayed by an array. Here we use a multidimensional array.
The array is used in many management systems like a library, students, parliament, etc.
The array is used in the online ticket booking system. Contacts on a cell phone are displayed by
this array.
In games like online chess, where the player can store his past moves as well as current moves. It
indicates a hint of position.
To save images in a specific dimension in the android Like 360*1200
Linked List
A linked list is a linear data structure where each node contains a value and a reference to the next
node. Here are some common operations performed on linked lists:
Initialization: A linked list can be initialized by creating a head node with a reference to the first
node. Each subsequent node contains a value and a reference to the next node.
Inserting elements: Elements can be inserted at the head, tail, or at a specific position in the
linked list.
Deleting elements: Elements can be deleted from the linked list by updating the reference of
the previous node to point to the next node, effectively removing the current node from the
list.
Searching for elements: Linked lists can be searched for a specific element by starting from the
head node and following the references to the next nodes until the desired element is found.
Updating elements: Elements in a linked list can be updated by modifying the value of a specific
node.
Traversing elements: The elements in a linked list can be traversed by starting from the head
node and following the references to the next nodes until the end of the list is reached.
Reversing a linked list: The linked list can be reversed by updating the references of each node
so that they point to the previous node instead of the next node.
These are some of the most common operations performed on linked lists. The specific operations
and algorithms used may vary based on the requirements of the problem and the programming
language used.
Applications of the Linked list:
Different applications of linked lists are as follows:
Linked lists are used to implement stacks, queues, graphs, etc.
Linked lists are used to perform arithmetic operations on long integers.
It is used for the representation of sparse matrices.
It is used in the linked allocation of files.
It helps in memory management.
It is used in the representation of Polynomial Manipulation where each polynomial term
represents a node in the linked list.
Linked lists are used to display image containers. Users can visit past, current, and next images.
They are used to store the history of the visited page.
They are used to perform undo operations.
Linked are used in software development where they indicate the correct syntax of a tag.
Linked lists are used to display social media feeds.
STACK:
Stack is a linear data structure that follows a particular order in which the operations are
performed. The order is LIFO(Last in first out). Entering and retrieving data is possible from only one
end. The entering and retrieving of data is also called push and pop operation in a stack. There are
different operations possible in a stack like reversing a stack using recursion, Sorting, Deleting the
middle element of a stack, etc.
Characteristics of a Stack:
Stack has various different characteristics which are as follows:
Stack is used in many different algorithms like Tower of Hanoi, tree traversal, recursion, etc.
Stack is implemented through an array or linked list.
It follows the Last In First Out operation i.e., an element that is inserted first will pop in last and
vice versa.
The insertion and deletion are performed at one end i.e. from the top of the stack.
In stack, if the allocated space for the stack is full, and still anyone attempts to add more
elements, it will lead to stack overflow.
Applications of Stack:
Different applications of Stack are as follows:
The stack data structure is used in the evaluation and conversion of arithmetic expressions.
Stack is used in Recursion.
It is used for parenthesis checking.
While reversing a string, the stack is used as well.
Stack is used in memory management.
It is also used for processing function calls.
The stack is used to convert expressions from infix to postfix.
The stack is used to perform undo as well as redo operations in word processors.
The stack is used in virtual machines like JVM.
The stack is used in the media players. Useful to play the next and previous song.
The stack is used in recursion operations.
A stack is a linear data structure that implements the Last-In-First-Out (LIFO) principle. Here are
some common operations performed on stacks:
Push: Elements can be pushed onto the top of the stack, adding a new element to the top of the
stack.
Pop: The top element can be removed from the stack by performing a pop operation,
effectively removing the last element that was pushed onto the stack.
Peek: The top element can be inspected without removing it from the stack using a peek
operation.
IsEmpty: A check can be made to determine if the stack is empty.
Size: The number of elements in the stack can be determined using a size operation.
These are some of the most common operations performed on stacks. The specific operations and
algorithms used may vary based on the requirements of the problem and the programming
language used. Stacks are commonly used in applications such as evaluating expressions,
implementing function call stacks in computer programs, and many others.
Real-Life Applications of Stack:
Real life example of a stack is the layer of eating plates arranged one above the other. When
you remove a plate from the pile, you can take the plate to the top of the pile. But this is exactly
the plate that was added most recently to the pile. If you want the plate at the bottom of the
pile, you must remove all the plates on top of it to reach it.
Browsers use stack data structures to keep track of previously visited sites.
Call log in mobile also uses stack data structure.
QUEUE:
Queue is a linear data structure that follows a particular order in which the operations are
performed. The order is First In First Out(FIFO) i.e. the data item stored first will be accessed first. In
this, entering and retrieving data is not done from only one end. An example of a queue is any
queue of consumers for a resource where the consumer that came first is served first. Different
operations are performed on a Queue like Reversing a Queue (with or without using recursion),
Reversing the first K elements of a Queue, etc. A few basic operations performed In Queue are
enqueue, dequeue, front, rear, etc.
Characteristics of a Queue:
The queue has various different characteristics which are as follows:
The queue is a FIFO (First In First Out) structure.
To remove the last element of the Queue, all the elements inserted before the new element in
the queue must be removed.
A queue is an ordered list of elements of similar data types.
Applications of Queue:
Different applications of Queue are as follows:
Queue is used for handling website traffic.
It helps to maintain the playlist in media players.
Queue is used in operating systems for handling interrupts.
It helps in serving requests on a single shared resource, like a printer, CPU task scheduling, etc.
It is used in the asynchronous transfer of data e.g. pipes, file IO, and sockets.
Queues are used for job scheduling in the operating system.
In social media to upload multiple photos or videos queue is used.
To send an e-mail queue data structure is used.
To handle website traffic at a time queues are used.
In Windows operating system, to switch multiple applications.
TREE:
A tree is a non-linear and hierarchal data structure where the elements are arranged in a tree-like
structure. In a tree, the topmost node is called the root node. Each node contains some data, and
data can be of any type. It consists of a central node, structural nodes, and sub-nodes which are
connected via edges. Different tree data structures allow quicker and easier access to the data as it
is a non-linear data structure. A tree has various terminologies like Node, Root, Edge, Height of a
tree, Degree of a tree, etc.
There are different types of Tree-like
Binary Tree,
Binary Search Tree,
AVL Tree,
B-Tree, etc.
Tree
Characteristics of a Tree:
The tree has various different characteristics which are as follows:
A tree is also known as a Recursive data structure.
In a tree, the Height of the root can be defined as the longest path from the root node to the
leaf node.
In a tree, one can also calculate the depth from the top to any node. The root node has a depth
of 0.
Applications of Tree:
Different applications of Tree are as follows:
Heap is a tree data structure that is implemented using arrays and used to implement priority
queues.
B-Tree and B+ Tree are used to implement indexing in databases.
Syntax Tree helps in scanning, parsing, generation of code, and evaluation of arithmetic
expressions in Compiler design.
K-D Tree is a space partitioning tree used to organize points in K-dimensional space.
Spanning trees are used in routers in computer networks.
A tree is a non-linear data structure that consists of nodes connected by edges. Here are some
common operations performed on trees:
Insertion: New nodes can be added to the tree to create a new branch or to increase the height
of the tree.
Deletion: Nodes can be removed from the tree by updating the references of the parent node
to remove the reference to the current node.
Search: Elements can be searched for in a tree by starting from the root node and traversing the
tree based on the value of the current node until the desired node is found.
Traversal: The elements in a tree can be traversed in several different ways, including in-order,
pre-order, and post-order traversal.
Height: The height of the tree can be determined by counting the number of edges from the
root node to the furthest leaf node.
Depth: The depth of a node can be determined by counting the number of edges from the root
node to the current node.
Balancing: The tree can be balanced to ensure that the height of the tree is minimized and the
distribution of nodes is as even as possible.
These are some of the most common operations performed on trees. The specific operations and
algorithms used may vary based on the requirements of the problem and the programming
language used. Trees are commonly used in applications such as searching, sorting, and storing
hierarchical data.
Real-Life Applications of Tree:
In real life, tree data structure helps in Game Development.
It also helps in indexing in databases.
A Decision Tree is an efficient machine-learning tool, commonly used in decision analysis. It has
a flowchart-like structure that helps to understand data.
Domain Name Server also uses a tree data structure.
The most common use case of a tree is any social networking site.
GRAPH:
A graph is a non-linear data structure that consists of vertices (or nodes) and edges. It consists of a
finite set of vertices and set of edges that connect a pair of nodes. The graph is used to solve the
most challenging and complex programming problems. It has different terminologies which are
Path, Degree, Adjacent vertices, Connected components, etc.
Graph
Characteristics of Graph:
The graph has various different characteristics which are as follows:
The maximum distance from a vertex to all the other vertices is considered the Eccentricity of
that vertex.
The vertex having minimum Eccentricity is considered the central point of the graph.
The minimum value of Eccentricity from all vertices is considered the radius of a connected
graph.
Applications of Graph:
Different applications of Graphs are as follows:
The graph is used to represent the flow of computation.
It is used in modeling graphs.
The operating system uses Resource Allocation Graph.
Also used in the World Wide Web where the web pages represent the nodes.
The binary search tree is a node – based non linear data structure that analyzes the node,
its left, and right branches, and arranged in a tree structure format.
The value of the key of the left sub-tree is less than the value of its parent (root) node's key.
The value of the key of the right sub-tree is greater than or equal to the value of its parent
(root) node's key.
Basic operations performed by BST are search, insert, pre-order, in-order, and post-order traversal.
Features of BST:
Binary Search Tree Traversal – Inorder, Preorder, Post Order for BST
In this tutorial, you will learn what a binary search tree is, what parts make up a tree, and some of
the common terms we use when describing parts of a tree.
We will also see how to traverse a tree using some of the common algorithms – all illustrated with
clear examples.
We can use the binary search tree for the addition and deletion of items in a tree.
We can also represent data in a ranked order using a binary tree. And in some cases, it can be used
as a chart to represent a collection of information.
The major importance of tree traversal is that there are multiple ways of carrying out traversal
operations unlike linear data structures like arrays, bitmaps, matrices where traversal is done in a
linear order.
Each of these methods of traversing a tree have a particular order they follow:
For Inorder, you traverse from the left subtree to the root then to the right subtree.
For Preorder, you traverse from the root to the left subtree then to the right subtree.
For Post order, you traverse from the left subtree to the right subtree then to the root.
Here is another way of representing the information above:
Remember that the values of the nodes on the left subtree are always smaller than the value of the
root node. Also, the values of the nodes on the right subtree are larger than the value of the root
node.
D, B, E, A, F, C, G
If that seems a bit complex for you to understand, then follow the order of the colors in the picture
below
Inorder traversal
How to Traverse a Tree Using Preorder Traversal
The order here is Root, Left, Right.
A, B, D, E, C, F, G
Here is the same diagram with different colors used as a guide:
Preorder traversal
D, E, B, F, G, C, A
If you can't figure out how we arrived at that result, then use the colors in the picture below as a
guide:
Postorder traversal
Example 1
Binary Search Tree (BST) for the following sequence of numbers-
47, 55, 23, 17, 39, 11, 50,
Always consider the first element as the root node. Consider the given elements and insert them in
the BST one by one.
Answer: