Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
6 views
Introduction To Data Structures and Algorithms
data structures
Uploaded by
aumar moctar
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Introduction_to_Data_Structures_and_Algorithms For Later
Download
Save
Save Introduction_to_Data_Structures_and_Algorithms For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
6 views
Introduction To Data Structures and Algorithms
data structures
Uploaded by
aumar moctar
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Introduction_to_Data_Structures_and_Algorithms For Later
Carousel Previous
Carousel Next
Save
Save Introduction_to_Data_Structures_and_Algorithms For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 5
Search
Fullscreen
9722721, 1:28 AME 68240: Data Svuctures & Algorthms | CS240 -- Lecture Notes: Introduction to Data Structures and Algorithms Daisy Tang Back To Lectures Notes This lecture gives a big picture of data structures and algorithms. It is adapted from Dr. Chung Lee's notes and Chapters from our textbook and reference book. Overview ‘Data Element borin < so cea, Data Structure: ‘piace Seen Jesplermertation -Algerithm Restricted Access Linear < ‘Simple Unrestricted Access Date Element Organization Corpeund ‘Tree Non ln Graph ie rain Data Structures, ADTs, and Algorithms Why data structures’ Ultimate goal -- to write efficient programs. In order to do that, one needs to organize the data in such a way that it can be accessed and manipulated efficiently. What are data structures? There are many definitions available + A data structure is an aggregation of data components that together constitute a meaningful whole. A data structure is a way of arranging data in a computer's memory or other disk storage. * A data structure is a collection of data, organized so that items can be stored and retrieved by some fixed techniques. Example: Suppose you are hired to create a database of names with all company's management and employees. ‘You can make a list. You can also make a tree, hitpsswwwccpp.edu/~fangicourses/CS24Oecturesintro.him 1892221, 11:28AM 68240: Data Sutures & Algorthms | a Aaron Manager Charles ve George Employee Jack Employee Janet ve John President 5 2 se ‘There are several common data structures: arrays, linked lists, queues, stacks, binary trees, hash tables, ete. These data structures can be classified as either linear or nonlinear data structures, based on how the data is, conceptually organized or aggregated. Linear structures. The array, list, queue, and stack belong to this category. Each of them is a collection that stores its entries in a linear sequence, and in which entries may be added or removed at will. They differ in the restrictions they place on how these entries may be added, removed, or accessed, ‘The common restrictions include FIFO and LIFO, Non-linear structures. Trees and graphs are classical non-linear structures. Data entries are not arranged in a sequence, but with different rules. are abstract data types (ADT)? The abstract view of a television: + Ability to change channels, adjust the volume + TV displays the show we want to watch ‘+ Don't care: who made the TV, or how circuit inside was constructed Remember the goal of software development? Robustness, adaptability, and reusability. Out of this effort to write better code arose a new metaphor for using and building data structures: abstract data type, which highlights the notion of abstraciness. When we say "data type", we often refer to the primitive data types built into a language, such as integer, real, character, and boolean. An integer, is most likely implemented or represented in four bytes in the computer. However, when we use integers, we do not worry at all about its internal representation, or how these operations are implemented by the compiler in machine code. Additionally, we know that, even when we run our program on a different machine, the behavior of an integer does not change, even though its internal representation may change. What we know is that we can use primitive data types via their operational interfaces -'#',"“,"™" and for integers. The primitive data types were abstract entries. hitpsswwwccpp.edu/~fangicourses/CS24Oecturesintro.him 26ov22ias, 14.28 AM 8240: Data Sructues & Algonthns Applying the idea of abstraction to data structures, we have ADT for data structures. On the one hand, an ADT makes a clean separation between interface and implementation, the user only sees the interface and therefore does not need to tamper with the implementation, On the other hand, if the implementation of an ADT changes, the code that uses the ADT does not break, since the interface remains the same. Thus, the abstraction makes the code more robust and easy to maintain. Moreover, once an ADT is built, it may be used multiple times in various contexts. For example, the list ADT may be used directly in application code, or may be used to build another ADT, such as a stack. We will learn more on the next ADT lecture, How do I choose the right data structures? When writing a program, one of the first steps is determining or choosing the data structures. What are the “right” data structures for the program? ‘The interface of operations supported by a data structure is one factor to consider when choosing between several available data structures. Another important factor is the efficiency of the data structure: how much space does the data structure occupy, and what are the running times of the ‘operations in its interface? We will look at a specific example later. What is an algorithm? There are many definition of algorithms. An algorithm is a procedure, a finite set of well-defined instructions, for solving a problem which, given an initial state, will terminate in a defined end-state. The computational complexity and efficient implementation of the algorithm are important in computing, and this depends on suitable data structures. ‘There are many different ways to express an algorithm, including natural language, pseudocode, flowcharts, and programming languages. Natural language expressions of algorithms tend to be verbose and ambiguous, and are rarely used for complex or technical algorithms. Pseudocode and flowcharts are structured ways to express algorithms that avoid many of the ambiguities common in natural language statements, while remaining independent of a particular implementation language. Programming languages are primarily intended for expressing algorithms in a form that can be executed by a computer, but are often used as a way to define or document algorithms Requirements of an algorithm: unambiguous, finite, feasible (effective), with input/output. Program efficiency: time vs. space. It is interesting to know how much of a particular resource (such as time or storage) is required for a given algorithm. Methods have been developed for the analysis of algorithms to obtain such quantitative answers, such as the big O notation. For example, the time needed for traversing an array of n slots is proportional to n, and we say the time is in the order of O(n). However, a 1g the ith clement in an array takes only constant time, which is independent of the size of the array, thus is in the order of OU), ‘The Phases of Software Development The development process includes the following steps (not necessarily in order): Specification of the task Design of a solution Implementation (coding) of the solution s of the solution Testing and debugging Maintenance ge Specification: hitpsswwwccpp.edu/~fangicourses/CS24Oecturesintro.him as920, 11:28 AM 8240; Data Sructures& Algor A specification is a precise description of the problem, Customers usually have an abstract idea of what they want as an end result, but not what software should do. Software engineers at this point should help them to rewrite incomplete, ambiguous, or even contradictory requirements in order to have a clear specification. This phase is also known as requirement analysis. De in techniques: Design of a solution involves: user interface design, selection of data structures, and formulating algorithms. There are many design techniques available. One good technique for designing an algorithm is to break down the task at hand into a few subtasks, then decompose each subtask into smaller subtasks, until the subtask is trivial to be solved (divide-and-conquer). Implementation Implementation is to write actual code to carry out the design. Analysis Time analysis vs. space analysis. Worst-case, average-case and best-case analyses. Usually we use the frequency count to compare algorithms. Consider the following three programs: reaiatitmtis La EL) Pesan grant) cere a Test ig Testing is used to make software free of syntax and logic errors. To serve as good test data, your test inputs need two properties: 1. You must know what output a correct program should produce for each test input (normal values). 2. The test inputs should include those inputs that are most likely to cause errors (abnormal and boundary values). ‘A boundary value of a problem is an input that is one step away from a different kind of behavior. For example, a text box is supposed to accept values in range of 1 to 100. Test cases include: * Values in between I and 100 (normal) © 0,1, 2,99, 100, 101 (boundary) ‘* Negative values and extremely large values (abnormal) Fully exercising code: make sure that each line of your code is executed at least once by some of your test data, If there is part of your code that is sometimes skipped altogether, make sure there is at least one test input that actually does not skip this part of your code Maintenance htps:iwwwcopp.edul-langicourses/CS240nectur 46922921, 11:28AM 68240: Data Svuctures & Algorthms | Rules and policies are always changing (for example, tax rate), so make sure changes and enhancements are up to date. Exercise Suppose you write a program that accepts a single line as input and then outputs a message telling whether or not the line contains the letter A and whether or not it contains more than three A's. What is a good set of test inputs? Last updated: Sept. 2012 hitpsswwwccpp.edu/~fangicourses/CS24Oecturesintro.him 58
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6125)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (932)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8214)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2922)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
3.5/5 (2061)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2530)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Yes Please
From Everand
Yes Please
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel