This document provides an overview of a course on data structures and algorithm analysis. It introduces some key data structures like arrays, linked lists, stacks, and queues. It also discusses algorithm strategies such as brute force, greedy, and divide-and-conquer algorithms. The course contents are described, including reviewing programming concepts, fundamental data structures and algorithms, recursion, and more. Assessment includes assignments, quizzes, class tests, and a final exam. Common operations on data structures like traversal, insertion, deletion, and searching are explained.
This document provides an introduction and overview of data structures and algorithms. It begins by outlining the topics that will be covered, including data structures, algorithms, abstract data types, and object-oriented programming. It then defines what a data structure is and provides examples. Different types of data structures are discussed, including linear structures like lists, queues, and stacks, as well as non-linear structures like trees, graphs, and hash tables. The document also defines what an algorithm is and discusses why algorithms are important. It provides examples of successful algorithms and discusses the need for correctness and efficiency in algorithms. The relationship between programs, data structures, and algorithms is also briefly explained.
This document provides an introduction to data structures and algorithms. It defines data as quantities, characters, or symbols operated on by a computer. Data structures are described as organized ways to store and access data efficiently. Common data structures include arrays, linked lists, trees, stacks, and queues. Algorithms are sets of instructions to solve problems, taking input and producing output. Good algorithms are correct, unambiguous, and efficient. Examples demonstrate data structures like arrays and graphs, as well as a simple maximum-finding algorithm. The conclusion emphasizes the importance of data structures.
The document provides information about data structures and algorithms. It defines key terms like data, information, data structure, algorithm and different types of algorithms. It discusses linear data structures like arrays, operations on arrays like traversing, searching, inserting and deleting elements. It also covers recursive functions, recursion concept, searching algorithms like sequential search and binary search along with their algorithms and examples.
This document discusses various applications of common data structures like linked lists, stacks, queues, and trees. It provides examples of how linked lists are used to implement queues and stacks, and in web browsers to store browsing history. It also gives examples of how stacks can be used for reversing words, undo/redo functions, matching parentheses in compilers, and modeling real-world examples like plates in a cupboard. Applications of queues include asynchronous data transfer and resource sharing. Trees are used in operating systems to represent folder structures, in HTML for the document object model, for network routing, syntax trees in compilers, and modeling game moves in AI.
This document discusses data structures and their importance in computer programming. It defines a data structure as a scheme for organizing related data that considers both the items stored and their relationships. Data structures are used to store data efficiently and allow for operations like searching and modifying the data. The document outlines common data structure types like arrays, lists, matrices, and linked lists. It also discusses abstract data types and how they are implemented through data structures. The goals of the course are to learn commonly used data structures and how to measure the costs and benefits of different structures.
This document provides an introduction to data structures and algorithms. It defines data structures as organized collections of data and describes common types including primitive, non-primitive, linear, and non-linear data structures. It also defines algorithms as step-by-step problem solving processes and discusses characteristics like finite time completion. The document outlines ways to measure algorithm efficiency including time and space complexity and asymptotic notation.
This document discusses algorithms and their complexity. It provides an example of a linear search algorithm to find a target value in an array. The complexity of this algorithm is analyzed for the worst and average cases. In the worst case, the target is the last element and all n elements must be checked, resulting in O(n) time complexity. On average, about half the elements (n+1)/2 need to be checked, resulting in average time complexity of O(n).
1. Data structures organize data in memory for efficient access and processing. They represent relationships between data values through placement and linking of the values.
2. Algorithms are finite sets of instructions that take inputs, produce outputs, and terminate after a finite number of unambiguous steps. Common data structures and algorithms are analyzed based on their time and space complexity.
3. Data structures can be linear, with sequential elements, or non-linear, with branching elements. Abstract data types define operations on values independently of implementation through inheritance and polymorphism.
this is a briefer overview about the Big O Notation. Big O Notaion are useful to check the Effeciency of an algorithm and to check its limitation at higher value. with big o notation some examples are also shown about its cases and some functions in c++ are also described.
Data may be organized in many different ways; the logical or mathematical model of a particular organization of data is called "Data Structure". The choice of a particular data model depends on two considerations:
It must be rich enough in structure to reflect the actual relationships of the data in the real world.
The structure should be simple enough that one can effectively process the data when necessary.
Data Structure Operations
The particular data structure that one chooses for a given situation depends largely on the nature of specific operations to be performed.
The following are the four major operations associated with any data structure:
i. Traversing : Accessing each record exactly once so that certain items in the record may be processed.
ii. Searching : Finding the location of the record with a given key value, or finding the locations of all records which satisfy one or more conditions.
iii. Inserting : Adding a new record to the structure.
iv. Deleting : Removing a record from the structure.
Primitive and Composite Data Types
Primitive Data Types are Basic data types of any language. In most computers these are native to the machine's hardware.
Some Primitive data types are:
Integer
This document discusses various data structures in C#, including arrays, lists, queues, stacks, hash tables, and more. It provides code examples and explains the time complexity of common operations for each data structure. Asymptotic analysis and big-O notation are introduced for analyzing how efficiently a data structure handles operations as its size increases.
Data structure and algorithm using javaNarayan Sau
This presentation created for people who like to go back to basics of data structure and its implementation. This presentation mostly helps B.Tech , Bsc Computer science students as well as all programmer who wants to develop software in core areas.
Introductiont To Aray,Tree,Stack, QueueGhaffar Khan
This document provides an introduction to data structures and algorithms. It defines key terminology related to data structures like entities, fields, records, files, and primary keys. It also describes common data structures like arrays, linked lists, stacks, queues, trees, and graphs. Finally, it discusses basic concepts in algorithms like control structures, complexity analysis, and examples of searching algorithms like linear search and binary search.
Data structure & algorithms introductionSugandh Wafai
The document discusses data structures and algorithms. It defines key concepts like data items, entities, attributes, and data processing operations. It then describes common linear data structures like arrays, linked lists, stacks, and queues. Non-linear structures like trees and graphs are also covered. Common algorithms for traversing, searching, inserting, deleting, sorting, and merging data are listed. The concepts of abstract data types and algorithm analysis are briefly introduced.
This document provides an overview of different data structures and sorting algorithms. It begins with an introduction to data structures and describes linear data structures like arrays, stacks, queues, and linked lists as well as non-linear data structures like trees and graphs. It then provides more detailed descriptions of stacks, queues, linked lists, and common sorting algorithms like selection sort and bubble sort.
The document discusses data structures and algorithms. It defines arrays as a series of objects of the same size and type, where each object is an element that can be accessed via an index. Algorithms are described as finite sequences of instructions to solve problems, with analysis of algorithms determining the resources like time and storage required.
This document discusses computer algorithms and provides examples of algorithms in Python. It begins by defining an algorithm and providing examples of sorting algorithms like insertion sort, selection sort, and merge sort. It then discusses searching algorithms like linear search and binary search, including their time complexities. Other topics covered include advantages of Python, types of problems solved by algorithms, and limitations of binary search.
This document provides an overview of an introductory course on algorithms and data structures. It discusses key topics that will be covered including introduction to algorithms, complexity analysis, algorithm design strategies like divide and conquer, and data structures. Specific examples of algorithms and data structures are provided like sorting, searching, linked lists, stacks, queues, trees and graphs. Implementation tools for algorithms like pseudo code and flowcharts are also introduced.
This document describes a course on data structures and algorithms. The course covers fundamental algorithms like sorting and searching as well as data structures including arrays, linked lists, stacks, queues, trees, and graphs. Students will learn to analyze algorithms for efficiency, apply techniques like recursion and induction, and complete programming assignments implementing various data structures and algorithms. The course aims to enhance students' skills in algorithm design, implementation, and complexity analysis. It is worth 4 credits and has prerequisites in computer programming. Student work will be graded based on assignments, exams, attendance, and a final exam.
This document provides an introduction to data structures and algorithms. It discusses why they are important for programming and problem solving. It defines key concepts like abstract data types, data structures, algorithms, and algorithm analysis. It also covers different ways of classifying data structures and analyzing the time and space complexity of algorithms. The goal is to help students understand fundamental concepts around organizing data and designing efficient computational procedures.
The document discusses algorithms and data structures. It defines an algorithm as a step-by-step procedure for solving a problem using a computer in a finite number of steps. It categorizes common types of algorithms as search, sort, insert, update, and delete algorithms. The document also defines a data structure as a way to store and organize data for efficient use. It distinguishes between linear and non-linear as well as static and dynamic data structures. Finally, it discusses algorithm design strategies like divide and conquer, merge sort, and dynamic programming.
The document discusses data structures and algorithms. It defines data structures and different types including primitive and non-primitive structures. It describes operations on data structures like traversing, searching, insertion and deletion. It also defines concepts like abstract data types, asymptotic analysis, and different algorithm analysis methods. Examples provided include linear search algorithm and binary search algorithm in pseudocode and C code.
Chapter 1 Introduction to Data Structures and Algorithms.pdfAxmedcarb
Data structures provide an efficient way to store and organize data in a computer so that it can be used efficiently. They allow programmers to handle data in an enhanced way, improving software performance. There are linear data structures like arrays and linked lists, and non-linear structures like trees and graphs. Common operations on data structures include insertion, deletion, searching, sorting, and merging. Asymptotic analysis is used to define the time complexity of algorithms in the average, best, and worst cases.
This document provides an overview of data structures and algorithms. It discusses key concepts like interfaces, implementations, time complexity, space complexity, asymptotic analysis, and common control structures. Some key points:
- A data structure organizes data to allow for efficient operations. It has an interface defining operations and an implementation defining internal representation.
- Algorithm analysis considers best, average, and worst case time complexities using asymptotic notations like Big O. Space complexity also measures memory usage.
- Common control structures include sequential, conditional (if/else), and repetitive (loops) structures that control program flow based on conditions.
This document provides an overview of a course on data structures and algorithms. The course covers fundamental data structures like arrays, stacks, queues, lists, trees, hashing, and graphs. It emphasizes good programming practices like modularity, documentation and readability. Key concepts covered include data types, abstract data types, algorithms, selecting appropriate data structures based on efficiency requirements, and the goals of learning commonly used structures and analyzing structure costs and benefits.
Rajat Kumar submitted a project report for partial fulfillment of his B.Tech degree in computer science from Lovely Professional University. The project involved developing a snake game where the player moves a snake to eat fruit without touching itself or the border, which ends the game. The report provided background on data structures, algorithms, common data structures like stacks and queues, and algorithm design techniques like recursion, dynamic programming, and backtracking. It concluded that data structures are important tools that enable efficient information storage, data management, and algorithm design.
In this educational video, we will provide an introduction to data structures. You will learn what data structures are, including queues, stacks, trees, and binary search. We will explore different types of data structures and specifically dive into priority queues. By watching this ppt, you will gain knowledge and have the opportunity to improve your command of data structures. Don't miss this chance to learn something new and expand your understanding.
part 1 - intorduction data structure 2021 mte.pptabdoSelem1
The document outlines a course on data structures and algorithms that is divided into 6 main parts covering various data structures, algorithms for sorting and searching, and programming concepts. The objectives of the course are to familiarize students with data structures, algorithms, and analyzing algorithm efficiency. Assessment will be based on assignments, projects, exams, and class participation.
This document provides an introduction to the CSC112 Algorithms and Data Structures lecture. It discusses the need for data structures to organize data efficiently and enable more complex applications. Different types of data structures are presented, including linear structures like arrays, lists, queues and stacks, as well as non-linear structures like trees and graphs. Key data structure operations like traversing, searching, inserting and deleting records are also outlined. The document emphasizes that the choice of data structure and algorithm can significantly impact a program's efficiency and performance.
The document discusses data structures and their importance in organizing data efficiently for computer programs. It defines what a data structure is and how choosing the right one can improve a program's performance. Several examples are provided to illustrate how analyzing a problem's specific needs guides the selection of an optimal data structure.
The document discusses data structures and their importance in organizing data efficiently for computer programs. It defines what a data structure is and how choosing the right one can improve a program's performance. Several examples are provided to illustrate how analyzing a problem's specific needs guides the selection of an optimal data structure.
This document provides an overview of advanced data structures and algorithms. It defines data structures as a way to store and organize data for efficient access and modification. The document then reviews basic concepts like variables, data types, and algorithms. It describes common data structures like arrays, linked lists, stacks, queues, trees, and hash tables. It also covers topics like asymptotic analysis, algorithms analysis, and the substitution method for solving algorithm recurrences. The document is an introduction to advanced data structure and algorithm concepts.
This document provides lecture notes on data structures that cover key topics including:
- Classifying data structures as simple, compound, linear, and non-linear and providing examples.
- Defining abstract data types and algorithms, and explaining their structure and properties.
- Discussing approaches for designing algorithms and issues related to time and space complexity.
- Covering searching techniques like linear search and sorting techniques including bubble sort, selection sort, and quick sort.
- Describing linear data structures like stacks, queues, and linked lists and non-linear structures like trees and graphs.
The document discusses algorithms and data structures. It begins by introducing common data structures like arrays, stacks, queues, trees, and hash tables. It then explains that data structures allow for organizing data in a way that can be efficiently processed and accessed. The document concludes by stating that the choice of data structure depends on effectively representing real-world relationships while allowing simple processing of the data.
The document discusses key concepts related to data structures and algorithms. It defines data as values or sets of values that can be organized hierarchically into fields, records, and files. Entities have attributes that can be assigned values. Related entities form entity sets. Data structures organize data through fields, records, and files while supporting operations like searching, insertion, and deletion. Algorithms are step-by-step processes to solve problems in a finite number of steps. The efficiency of algorithms is measured by time and space complexity.
React and Next.js are complementary tools in web development. React, a JavaScript library, specializes in building user interfaces with its component-based architecture and efficient state management. Next.js extends React by providing server-side rendering, routing, and other utilities, making it ideal for building SEO-friendly, high-performance web applications.
Cultural Shifts: Embracing DevOps for Organizational TransformationMindfire Solution
Mindfire Solutions specializes in DevOps services, facilitating digital transformation through streamlined software development and operational efficiency. Their expertise enhances collaboration, accelerates delivery cycles, and ensures scalability using cloud-native technologies. Mindfire Solutions empowers businesses to innovate rapidly and maintain competitive advantage in dynamic market landscapes.
Software development... for all? (keynote at ICSOFT'2024)miso_uam
Our world runs on software. It governs all major aspects of our life. It is an enabler for research and innovation, and is critical for business competitivity. Traditional software engineering techniques have achieved high effectiveness, but still may fall short on delivering software at the accelerated pace and with the increasing quality that future scenarios will require.
To attack this issue, some software paradigms raise the automation of software development via higher levels of abstraction through domain-specific languages (e.g., in model-driven engineering) and empowering non-professional developers with the possibility to build their own software (e.g., in low-code development approaches). In a software-demanding world, this is an attractive possibility, and perhaps -- paraphrasing Andy Warhol -- "in the future, everyone will be a developer for 15 minutes". However, to make this possible, methods are required to tweak languages to their context of use (crucial given the diversity of backgrounds and purposes), and the assistance to developers throughout the development process (especially critical for non-professionals).
In this keynote talk at ICSOFT'2024 I presented enabling techniques for this vision, supporting the creation of families of domain-specific languages, their adaptation to the usage context; and the augmentation of low-code environments with assistants and recommender systems to guide developers (professional or not) in the development process.
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...Hironori Washizaki
Hironori Washizaki, "Charting a Course for Equity: Strategies for Overcoming Challenges and Promoting Inclusion in the Metaverse", IEEE COMPSAC 2024 D&I Panel, 2024.
Ansys Mechanical enables you to solve complex structural engineering problems and make better, faster design decisions. With the finite element analysis (FEA) solvers available in the suite, you can customize and automate solutions for your structural mechanics problems and parameterize them to analyze multiple design scenarios. Ansys Mechanical is a dynamic tool that has a complete range of analysis tools.
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsEstuary Flow
Unlock the full potential of your data by effortlessly migrating from PostgreSQL to Snowflake, the leading cloud data warehouse. This comprehensive guide presents an easy-to-follow 8-step process using Estuary Flow, an open-source data operations platform designed to simplify data pipelines.
Discover how to seamlessly transfer your PostgreSQL data to Snowflake, leveraging Estuary Flow's intuitive interface and powerful real-time replication capabilities. Harness the power of both platforms to create a robust data ecosystem that drives business intelligence, analytics, and data-driven decision-making.
Key Takeaways:
1. Effortless Migration: Learn how to migrate your PostgreSQL data to Snowflake in 8 simple steps, even with limited technical expertise.
2. Real-Time Insights: Achieve near-instantaneous data syncing for up-to-the-minute analytics and reporting.
3. Cost-Effective Solution: Lower your total cost of ownership (TCO) with Estuary Flow's efficient and scalable architecture.
4. Seamless Integration: Combine the strengths of PostgreSQL's transactional power with Snowflake's cloud-native scalability and data warehousing features.
Don't miss out on this opportunity to unlock the full potential of your data. Read & Download this comprehensive guide now and embark on a seamless data journey from PostgreSQL to Snowflake with Estuary Flow!
Try it Free: https://dashboard.estuary.dev/register
What is OCR Technology and How to Extract Text from Any Image for FreeTwisterTools
Discover the fascinating world of Optical Character Recognition (OCR) technology with our comprehensive presentation. Learn how OCR converts various types of documents, such as scanned paper documents, PDFs, or images captured by a digital camera, into editable and searchable data. Dive into the history, modern applications, and future trends of OCR technology. Get step-by-step instructions on how to extract text from any image online for free using a simple tool, along with best practices for OCR image preparation. Ideal for professionals, students, and tech enthusiasts looking to harness the power of OCR.
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdfonemonitarsoftware
WhatsApp Tracker Software is an effective tool for remotely tracking the target’s WhatsApp activities. It allows users to monitor their loved one’s online behavior to ensure appropriate interactions for responsive device use.
Download this PPTX file and share this information to others.
Sami provided a beginner-friendly introduction to Amazon Web Services (AWS), covering essential terms, products, and services for cloud deployment. Participants explored AWS' latest Gen AI offerings, making it accessible for those starting their cloud journey or integrating AI into coding practices.
Lots of bloggers are using Google AdSense now. It’s getting really popular. With AdSense, bloggers can make money by showing ads on their websites. Read this important article written by the experienced designers of the best website designing company in Delhi –
In this talk, we will explore strategies to optimize the success rate of storing and retaining new information. We will discuss scientifically proven ideal learning intervals and content structures. Additionally, we will examine how to create an environment that improves our focus while you remain in the “flow”. Lastly we will also address the influence of AI on learning capabilities.
In the dynamic field of software development, this knowledge will empower you to accelerate your learning curve and support others in their learning journeys.
An MVP (Minimum Viable Product) mobile application is a streamlined version of a mobile app that includes only the core features necessary to address the primary needs of its users. The purpose of an MVP is to validate the app concept with minimal resources, gather user feedback, and identify any areas for improvement before investing in a full-scale development. This approach allows businesses to quickly launch their app, test its market viability, and make data-driven decisions for future enhancements, ensuring a higher likelihood of success and user satisfaction.
Attendance Tracking From Paper To DigitalTask Tracker
If you are having trouble deciding which time tracker tool is best for you, try "Task Tracker" app. It has numerous features, including the ability to check daily attendance sheet, and other that make team management easier.
3. COURSE INTRODUCTION
This course introduces students to learn about data elements which
provides an efficient way of storing and organizing data in the computer
so that it can be used efficiently.
Also about some of Data Structures such as arrays, Linked List, Stack,
Queue, etc.
Data Structures are widely used in almost every aspect of Computer
Science i.e. Operating System, Compiler Design, Artificial intelligence,
Graphics and many more.
4. Course Contents
Review of elementary programming concepts: Variables and Data
types, Conditional Statements, Looping Statements,Arrays.
Fundamental data structures: Stacks,Queues,Linked lists,Hash
tables,Trees,Graphs.
Fundamental computing algorithms :O(N log N) sorting algorithms
Binary search trees,Representations of graphs,Depth- and Breadth-first traversals.
Recursion :The concept of recursion,Recursive mathematical functions,Simple
recursive procedures,Divide-and-conquer strategies.
Algorithmic strategies,Brute-force algorithms,Greedy algorithms,Branch-and-
bound; Pattern matching and string/text algorithms; Numerical approximation algorithms
5. MODE OF ASSESSMENTS
CONTINUOUS ASSESSMENT Week Weight Remarks
ASSIGNMENTS
1-4 10% Subjective
CLASS TEST 6
10%
Subjective
QUIZ 3-8 10%
Subjective
FINAL EXAM 12 60%
Subjective
6. Data: Collection of raw facts.
Data structure is a specialized format for organizing and storing data in
memory that considers not only the elements stored but also their
to each other.
• Data structure Is an arrangement of data In computer's memory. It makes
data to be quickly available to the processor for required operations.
• It is a structure program used to store ordered data, so that various
operations can be performed on it easily.
It should be designed and implemented in such a way that it reduces the
complexity and increases the efficiency.
INTRODUCTION
7. INTRODUCTION
Data structure affects the design of both structural & functional aspects of
a program.
Program=algorithm + Data Structure
You know that a algorithm is a step by step procedure to solve a
particular function.
8. Classification of data structure
Data structure are normally divided into two broad categories:
Primitive Data Structure & NON-PRIMITIVE DATA
STRUCTURE
.
9. Primitive Data Structure
Data structures that are directly operated upon the machine-level
instructions are known as primitive or primary data structures.
Integer, Floating-point number, Character constants, string constants,
pointers etc, fall in this category as example of Simple data structure.
The most commonly used operation
on data structure are broadly
categorized into following types:
◦ Create
◦ Selection ◦ Updating
◦ Destroy or Delete
10. NON-PRIMITIVE DATA STRUCTURE
The Data structures that are derived from the primitive data structures are
called Non-primitive or secondary data structure.
The non-primitive data structures emphasize on structuring of a group of
homogeneous (same type) or heterogeneous ( different type) data items.
NON-PRIMITIVE DATA STRUCTURE IS DIVIDED INTO:
1. linear data structure
2. Non-linear data structure
NOTE There are more sophisticated data structures.
11. NON-PRIMITIVE DATA STRUCTURE
Linear Data structures:
◦ Linear Data structures are kind of data structure that has homogeneous elements.
◦ The data structure in which elements are in a sequence and form a liner series.
◦ Linear data structures are very easy to implement, since the memory of the computer is
also organized in a linear fashion.
◦ Some commonly used linear data structures are Stack, Queue and Linked Lists.
Non-Linear Data structures:
◦ A Non-Linear Data structures is a data structure in which data item is connected to
several other data items.
◦ Non-Linear data structure may exhibit either a hierarchical relationship or parent child
relationship.
◦ The data elements are not arranged in a sequential structure.
◦ some commonly non-linear data structures are trees and graphs.
12. OPERATIONS APPLIED ON DATA STRUCTURES
The most commonly used operation on data structure are broadly categorized
into following types:
◦ Traversal
◦ Insertion
◦ Selection
◦ Searching
◦ Sorting
◦ Merging
◦ Destroy or Delete
13. Different between A primitive data structure
and non primitive data structure
A primitive data structure is generally a basic structure that is usually built
into the language, such as an integer, a float.
A non-primitive data structure is built out of primitive data structures
linked together in meaningful ways, such as a or a linked-list, binary
search tree, AVL Tree, graph etc.
14. INTRODUCTION TO ALGORITHM
Algorithm is a step-by-step procedure, which defines a set of instructions to be
executed in a certain order to get the desired output.
Algorithms are generally created independent of underlying languages, i.e. an
algorithm can be implemented in more than one programming language
15. SOME IMPORTANT CATEGORIES OF ALGORITHMS
From the data structure point of view, following are some important
categories of algorithms −
Search − Algorithm to search an item in a data structure.
Sort − Algorithm to sort items in a certain order.
Insert − Algorithm to insert item in a data structure.
Update − Algorithm to update an existing item in a data structure.
Delete − Algorithm to delete an existing item from a data structure.
16. CHARACTERISTICS OF AN ALGORITHM
Not all procedures can be called an algorithm. An algorithm should have the following
characteristics −
Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or phases), and
their inputs/outputs should be clear and must lead to only one meaning.
Input − An algorithm should have 0 or more well-defined inputs.
Output − An algorithm should have 1 or more well-defined outputs, and should match the
desired output.
Finiteness − Algorithms must terminate after a finite number of steps.
Feasibility − Should be feasible with the available resources.
Independent − An algorithm should have step-by-step directions, which should be independent
of any programming code.
17. HOW TO WRITE AN ALGORITHM
There are no well-defined standards for writing algorithms. Rather, it is problem and
resource dependent. Algorithms are never written to support a particular programming
code.
As we know that all programming languages share basic code constructs like loops (do,
for, while), flow-control (if-else), etc. These common constructs can be used to write an
algorithm.
We write algorithms in a step-by-step manner, but it is not always the case. Algorithm
writing is a process and is executed after the problem domain is well-defined. That is,
we should know the problem domain, for which we are designing a solution.
18. HOW TO WRITE AN ALGORITHM
Example
Let's try to learn algorithm-writing by using an example.
Problem − Design an algorithm to add two numbers and display the result.
Step 1 − START
Step 2 − declare three integers a, b & c
Step 3 − define values of a & b
Step 4 − add values of a & b
Step 5 − store output of step 4 to c
Step 6 − print c
In design and analysis of algorithms, usually the second method is used to describe an algorithm. It
makes it easy for the analyst to analyze the algorithm ignoring all unwanted definitions. He can
observe what operations are being used and how the process is flowing.
Writing step numbers, is optional.
We design an algorithm to get a solution of a given problem. A problem can be solved in more
than one ways.
19. ALGORITHM ANALYSIS
Efficiency of an algorithm can be analyzed at two different stages, before implementation and after
implementation. They are the following −
A Priori Analysis − This is a theoretical analysis of an algorithm. Efficiency of an algorithm is measured
by assuming that all other factors, for example, processor speed, are constant and have no effect on
the implementation.
A Posterior Analysis − This is an empirical analysis of an algorithm. The selected algorithm is
implemented using programming language. This is then executed on target computer machine. In
this analysis, actual statistics like running time and space required, are collected.
We shall learn about a priori algorithm analysis. Algorithm analysis deals with the execution or running
time of various operations involved. The running time of an operation can be defined as the number
of computer instructions executed per operation.
20. Algorithm Complexity
Suppose X is an algorithm and n is the size of input data, the time and space used
by the algorithm X are the two main factors, which decide the efficiency of X.
Time Factor − Time is measured by counting the number of key operations such as
comparisons in the sorting algorithm.
Space Factor − Space is measured by counting the maximum memory space
required by the algorithm.
The complexity of an algorithm f(n) gives the running time and/or the storage space
required by the algorithm in terms of n as the size of input data.
21. SPACE COMPLEXITY
Space complexity of an algorithm represents the amount of memory space
required by the algorithm in its life cycle. The space required by an algorithm is
equal to the sum of the following two components
A fixed part that is a space required to store certain data and variables, that are
independent of the size of the problem. For example, simple variables and
constants used, program size, etc.
A variable part is a space required by variables, whose size depends on the size of
the problem. For example, dynamic memory allocation, recursion stack space, etc.
Space complexity S(P) of any algorithm P is S(P) = C + SP(I), where C is the fixed
part and S(I) is the variable part of the algorithm, which depends on instance
characteristic I. Following is a simple example that tries to explain the concept
22. TIME COMPLEXITY
Algorithm: SUM(A, B)
Step 1 - START
Step 2 - C ← A + B + 10
Step 3 - Stop
Here we have three variables A, B, and C and one constant. Hence S(P) = 1 + 3.
Now, space depends on data types of given variables and constant types and it
will be multiplied accordingly.
23. TIME Complexity
Time complexity of an algorithm represents the amount of time required
by the algorithm to run to completion. Time requirements can be defined
as a numerical function T(n), where T(n) can be measured as the number
of steps, provided each step consumes constant time.
For example, addition of two n-bit integers takes n steps. Consequently,
the total computational time is T(n) = c ∗ n, where c is the time taken for
the addition of two bits. Here, we observe that T(n) grows linearly as the
input size increases.
24. Description of various data structure
ARRAY
An array is defined as a set of finite number of homogeneous elements or same data items.
It means an array can contain one type of data only, either all integer, all float-point number or all
character.
One dimensional array
An array with only one row or column is called one-dimensional array.
It is finite collection of n number of elements of same type such that:
◦ can be referred by indexing.
◦ The syntax Elements are stored in continuous locations.
◦ Elements x to define one-dimensional array is:
Syntax: Datatype Array_Name [Size];
Where,
Datatype : Type of value it can store (Example: int, char, float) Array_Name: To identify the array.
Size : The maximum number of elements that the array can hold
25. ARRAY
Simply, declaration of array is as follows: int arr[10]
Where int specifies the data type or type of elements arrays
stores.
“arr” is the name of array & the number specified inside
the square brackets is the number of elements an array can
store, this is also called sized or length of array.
The elements of linear array are stored in consecutive
memory locations. It is shown below
26. ARRAY
◦ The elements of array will always be stored in the consecutive
(continues) memory location.
◦ The number of elements that can be stored in an array, that is the size
of array or its length is given by the following equation:
(Upperbound-lowerbound)+1
◦ For the above array it would be (9-0)+1=10,where 0 is the lower bound
of array and 9 is the upper bound of array.
◦ Array can always be read or written through loop.
For(i=0;i<=9;i++)
{scanf(“%d”,&arr[i]); printf(“%d”,arr[i]);
27. TYPES OF ARRAY
Single Dimension Array: Array with one subscript
Two Dimension Array: Array with two subscripts (Rows and Column)
Multi Dimension Array: Array with Multiple subscripts
28. Basic operations of Arrays
Some common operation performed on array are:
◦ Traversing
◦ Searching
◦ Insertion
◦ Deletion
◦ Sorting
◦ Merging
29. TRAVERSING
Traversing:It is used to access each data item
exactly once so that it can be processed. E.g.
We have linear array A as below:
0 1 2 3 4
10 20 30 40 50
Here we will start from beginning and will go till
last element and during this process we will
access value of each element exactly once as
below:
A [1] = 10 A [2] = 20
A [3] = 30
A [4] = 40
A [5] = 50
30. INSERTION
Insertion: It is used to add a new data item in the given collection of data
items.
E.g. We have linear array A as below:
12 3 4 5
10 20 50 30 15
New element to be inserted is 100 and location for insertion is 3. So shift
the elements from 5th location to 3rd location downwards by 1 place.
And then insert 100 at 3rd location. It is shown below:
32. DELETION OF ARRAYS
Deletion of arrays: It is used to delete an existing data item from the
given collection of data items
33. SEARCHING ARRAY
Searching: It is used to find out the location of the data item if it exists in the
given collection of data items.
E.g. We have linear array A as below:
12 3 4 5
15 50 35 20 25
Suppose item to be searched is 20. We will start from beginning and will compare
20 with each element. This process will continue until element is found or array is
finished. Here:
1) Compare 20 with 15 20 # 15, go to next element. 2) Compare 20 with 50 20
# 50, go to next element.
Compare 20 with 35 20 #35, go to next element.
Compare 20 with 20
20 = 20, so 20 is found and its location is 4.
35. BINARY SEARCH
algorithm can be used with
only sorted list of
elements.
Binary Search first divides
a large array into two
smaller sub -arrays and
then recursively operate
the sub -arrays.
Binary Search basically
reduces the search space to
half at each step