Dami Doc 2

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 12

ADMAS UNIVERSITY

DEPARTMENT OF COMPUTER SCIENCE DEGREPROGRAM INDIVIDUAL


ASSIGNMENT OF

DATA STRUCTURE AND ALGORITHM ANALYSIS

NAME ………………………………………………………………………………………ID No

1. DAME SORESA ………………………………………………………………...0338/21

SUB To: SULEMAN

May, 2023

Addis Abeba
1. Application of linked list

A linked list is a linear data structure, in which the elements are not stored at contiguous memory
locations.

Linked lists can be used to represent polynomials. Using a linked list, we can perform the
polynomial manipulation. Arithmetic operations like addition or subtraction of long integers can
also be performed using a linked list. The linked list can be used to implement stacks and queues.

There are many applications of linked lists, be it in computer science

Some of these Applications are:

 Linked lists can be used to represent polynomials.

 Using a linked list, we can perform the polynomial manipulation.

 Arithmetic operations like addition or subtraction of long integers can also be performed
using a linked list.

 The linked list can be used to implement stacks and queues.

 The linked list is also used in implementing graphs in which the adjacent vertices are
stored in the nodes of the linked list popularly known as Adjacency list representation.

Applications of Circular Linked Lists:

The circular linked list can be used to implement queues.

In web browsers, the back button is implemented using a circular linked list.

In an operating system, a circular linked list can be used in scheduling algorithms like the Round
Robin algorithm.

The undo functionality that is present in applications like photo editors etc., is implemented
using circular linked lists.

1
Circular linked lists can also be used to implement advanced data structures like MRU (Most
Recently Used) lists and Fibonacci heap.

Applications of Singly Linked List:

The singly linked list is used to implement stack and queue.

The undo or redo options, the back buttons, etc., that we discussed above are implemented using
a singly linked list.

During the implementation of a hash function, there arises a problem of collision, to deal with
this problem; a singly linked list is used.

Application of Doubly Linked Lists

It is also used in algorithms of LRU (Least Recently used) and MRU(Most Recently Used)
cache.

The undo and redo buttons can be implemented using a doubly-linked list.

The doubly linked list can also be used in the allocation and deallocation of memory.

2. Application of stack
A Stack can be used for evaluating expressions consisting of operands and operators.

Stack is a simple linear data structure used for storing data. Stack follows the LIFO (Last in First
Out) strategy that states that the element that is inserted last will come out first. You can take a
pile of plates kept on top of each other as a real-life example. The plate which we put last is on
the top and since we remove the plate that is at the top, we can say that the plate that was put last
comes out first. It can be implemented through an array or linked lists. Some of its main
operations are: push (), pop(), top(), is Empty(), size(), etc.

In order to make manipulations in a stack, there are certain operations provided to us. When we
want to insert an element into the stack the operation is known as the push operation whereas
when we want to remove an element from the stack the operation is known as the pop operation.

2
If we try to pop from an empty stack then it is known as underflow and if we try to push an
element in a stack that is already full, then it is known as overflow.

 Types of Stacks

Register Stack: This type of stack is also a memory element present in the memory unit and can
handle a small amount of data only. The height of the register stack is always limited as the size
of the register stack is very small compared to the memory.

Memory Stack: This type of stack can handle a large amount of memory data. The height of the
memory stack is flexible as it occupies a large amount of memory data.

What is meant by Top of the Stack?

When a new element is added to the stack, it is placed on top of the existing elements. Similarly,
when an element is removed from the stack, the topmost element is removed first. The top of the
stack is always the element that is currently accessible for viewing or manipulation.

The pointer through which the elements are accessed, inserted, and deleted in the stack is called
the top of the stack. It is the pointer to the topmost element of the stack.

Application of Stack Data Structure:

Function calls and recursion: When a function is called, the current state of the program is
pushed onto the stack. When the function returns, the state is popped from the stack to resume
the previous functions execution.

Undo/Redo operations: The undo-redo feature in various applications uses stacks to keep track of
the previous actions. Each time an action is performed, it is pushed onto the stack. To undo the
action, the top element of the stack is popped, and the reverse operation is performed.

Expression evaluation: Stack data structure is used to evaluate expressions in infix, postfix, and
prefix notations. Operators and operands are pushed onto the stack, and operations are performed
based on the stacks top elements.

3
Browser history: Web browsers use stacks to keep track of the web pages you visit. Each time
you visit a new page, the URL is pushed onto the stack, and when you hit the back button, the
previous URL is popped from the stack.

Balanced Parentheses: Stack data structure is used to check if parentheses are balanced or not.
An opening parenthesis is pushed onto the stack, and a closing parenthesis is popped from the
stack. If the stack is empty at the end of the expression, the parentheses are balanced.

Backtracking Algorithms: The backtracking algorithm uses stacks to keep track of the states of
the problem-solving process. The current state is pushed onto the stack, and when the algorithm
backtracks, the previous state is popped from the stack.

Application of Stack in real life:

 CD/DVD stand.

 Stack of books in a book shop.

 Call center systems.

 Undo and Redo mechanism in text editors.

 The history of a web browser is stored in the form of a stack.

 Call logs, E-mails, and Google photos in any gallery are also stored in form of a stack.

 YouTube downloads and Notifications are also shown in LIFO format (the latest appears
first ).

 Allocation of memory by an operating system while executing a process.

 Advantages of Stack:

Easy implementation: Stack data structure is easy to implement using arrays or linked lists, and
its operations are simple to understand and implement.

Efficient memory utilization: Stack uses a contiguous block of memory, making it more efficient
in memory utilization as compared to other data structures.
4
Fast access time: Stack data structure provides fast access time for adding and removing
elements as the elements are added and removed from the top of the stack.

Helps in function calls: Stack data structure is used to store function calls and their states, which
helps in the efficient implementation of recursive function calls.

Supports backtracking: Stack data structure supports backtracking algorithms, which are used in
problem-solving to explore all possible solutions by storing the previous states.

Used in Compiler Design: Stack data structure is used in compiler design for parsing and syntax
analysis of programming languages.

Enables undo/redo operations: Stack data structure is used to enable undo and redo operations in
various applications like text editors, graphic design tools, and software development
environments.

 Disadvantages of Stack:

Limited capacity: A stack data structure has a limited capacity as it can only hold a fixed number
of elements. If the stack becomes full, adding new elements may result in stack overflow, leading
to the loss of data.

No random access: Stack data structure does not allow for random access to its elements, and it
only allows for adding and removing elements from the top of the stack. To access an element in
the middle of the stack, all the elements above it must be removed.

Memory management: Stack data structure uses a contiguous block of memory, which can result
in memory fragmentation if elements are added and removed frequently.

Not suitable for certain applications: The stack data structure is not suitable for applications that
require accessing elements in the middle of the stack, like searching or sorting algorithms.

Stack overflow and underflow: Stack data structure can result in stack overflow if too many
elements are pushed onto the stack, and it can result in stack underflow if too many elements are
popped from the stack.

3. Application of Queue
5
A queue is a linear data structure that contains elements in an ordered sequence.

A queue is an ideal data structure for task scheduling which lets you perform all the tasks in
order. Initially, all the tasks are pushed to the end of the queue.

It is an abstract data type, pretty similar to a stack data structure and also different
fundamentally.

We insert data at one end of the queue and remove data from the other end.
Think of a queue at the railway station ticket counter. The person standing first in the queue
gets the ticket and leaves the group, while a new person joins at the back end of the queue.

 Types of Queue

There are different types of Queue some of this are:-

1. Simple Queue:- The simple queue is a normal queue where insertion takes place at

the FRONT of the queue and deletion takes place at the END of the queue.

In a simple queue, insertion takes place at the rear and removal occurs at the front. It strictly
follows the FIFO (First in First out) rule.

2. Circular Queue:- In a circular queue, the last node is connected to the first node.

A circular queue is also called as Ring Buffer.

Insertion in a circular queue happens at the FRONT and deletion at the END of the queue.

The main advantage of a circular queue over a simple queue is better memory utilization. If the
last position is full and the first position is empty, we can insert an element in the first position.
This action is not possible in a simple queue.

3. Priority Queue A priority queue is a special type of queue in which each element is
associated with a priority and is served according to its priority. If elements with the same
priority occur, they are served according to their order in the queue. In a priority queue,
the nodes will have some predefined priority.

 Insertion in a priority queue is performed in the order of arrival of the nodes.

6
 The node having the least priority will be the first to be removed from the priority queue.

4. Dequeue (Double Ended Queue):- In a Double Ended Queue, insertion and deletion

operations can be done at both FRONT and END of the queue.


Advantages of Queue:
 A large amount of data can be managed efficiently with ease.
 Operations such as insertion and deletion can be performed with ease as it follows
the first in first out rule.
 Queues are useful when a particular service is used by multiple consumers.
 Queues are fast in speed for data inter-process communication.
 Queues can be used in the implementation of other data structures.
Disadvantages of Queue:
 The operations such as insertion and deletion of elements from the middle are time
consuming.
 Limited Space.
 In a classical queue, a new element can only be inserted when the existing elements
are deleted from the queue.
 Searching an element takes O(N) time.
 Maximum size of a queue must be defined prior.
4. Application of hashing

Hashing:- is the process of converting a given key into another value. A hash function is used
to generate the new value according to a mathematical algorithm. The result of a hash function is
known as a hash value or simply, a hash.

A good hash function uses a one-way hashing algorithm or in other words, the hash cannot be
converted back into the original know.

Application of Hashing:-

 Database indexing: Hashing is used to index and retrieve data efficiently in databases and
other data storage systems.

7
 Password storage: Hashing is used to store passwords securely by applying a hash function
to the password and storing the hashed result, rather than the plain text password.

 Data compression: Hashing is used in data compression algorithms, such as the Huffman
coding algorithm, to encode data efficiently.

 Search algorithms: Hashing is used to implement search algorithms, such as hash tables and
bloom filters, for fast lookups and queries.

 Cryptography: Hashing is used in cryptography to generate digital signatures, message


authentication codes (MACs), and key derivation functions.

 Load balancing: Hashing is used in load-balancing algorithms, such as consistent hashing,


to distribute requests to servers in a network.

 Block chain: Hashing is used in block chain technology, such as the proof-of-work
algorithm, to secure the integrity and consensus of the block chain.

 Image processing: Hashing is used in image processing applications, such as perceptual


hashing, to detect and prevent image duplicates and modifications.

 File comparison: Hashing is used in file comparison algorithms, such as the MD5 and
SHA-1 hash functions, to compare and verify the integrity of files.

 Fraud detection: Hashing is used in fraud detection and cybersecurity applications, such as
intrusion detection and antivirus software, to detect and prevent malicious activities.

Hashing provides constant time search, insert and delete operations on average. This is why
hashing is one of the most used data structures, example problems are, distinct elements,
counting frequencies of items, finding duplicates, etc.

There are many other applications of hashing, including modern-day cryptography hash
functions.

Some of these applications are listed below:

 Message Digest
8
 Password Verification

 Data Structures(Programming Languages)

 Compiler Operation

 Rabin-Karp Algorithm

 Linking File name and path together

 Game boards

 Graphics

Advantage of Hashing

 Low cost

 It is comparing two files for equality

 It is transferred from one place to another in a file backup program

 Values can identify differences in file even when an encrypted file is designed in a
manner to disallow change in file size.

Disadvantage of Hashing

 Large number of collisions

 Increases with the amount of data

 A large number of hash functions do not have the ability to move to the next or previous
data set.

4.1. Application of Indexing:-


Application indexing: - has enabled search engines to provide search results from within
applications in addition to those from mobile or desktop websites.

Indexing:- is a data structure technique that helps to speed up data retrieval.

Advantages of application indexing

9
 Increased performance in searching for records

 Sorting records

 Maintaining a unique column

Disadvantage of application indexing

 Increased disk space

 Slower data modification

 Updating records in the clustered index

Advanced sorting:-

Is the processing of arranging the data in ascending and descending order.

Sorting is the process of arranging items in a specific order or sequence. It is a common


algorithmic problem in computer science and is used in various applications such as searching,
data analysis, and information retrieval.

Advanced searching:-

Are you can choose words or phrases to include or remove from your results? You can choose:
“All these words”: Results use all the words you enter. “This exact word or phrase”: Results
include one exact word or phrase you enter.

There are two types of advanced search:

 interval search

 sequential search

Almost every search algorithm falls into one of these two categories. Linear and binary searches
are two simple and easy-to-implement algorithms, with binary algorithms performing faster than
linear algorithms.

5. Advantages and Disadvantages of merge sort techniques


10
The merge sort algorithm has several advantages and disadvantages over other sorting
algorithms:

 Advantages merge sort techniques

It is quicker for larger lists unlike insertion and bubble sort; it doesn’t go through the whole list
several times.

It has a consistent running time and carries out different bits with similar times in a stage. it is a
stable sort, meaning that equal elements retain their relative order in the sorted output.

It is efficient for both small and large data sets, with a time complexity of O(n log n).

It is a divide-and-conquer algorithm, which means that it is relatively easy to understand and


implement.

It can be easily adapted to work with linked lists, making it useful for sorting data that is too
large to fit into memory.

It is also can be implemented in a parallel way, which can greatly speed up sorting large data
sets.

 Disadvantages Merge sort techniques

 Slower comparative to the other sort algorithms for smaller tasks.

 Goes through the whole process even i he list is sorted (just like insertion and bubble
sort?)

 Uses more memory space to store the sub elements of the initial split list.

11

You might also like