Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14
Bohol Island State University
INTRO TO DATA STRUCTURES AND ALGORITHMS
Alma Mae B. Auxtero
Learning Objectives • Discuss the need for using data structures and algorithms in computer programming • classify data structures based on their organization of elements; and • illustrate a real-world problem and determine the type of data structure that you can use to solve it. Basic Concepts • Data object - represents an object having data. • Data type - a classification of data such as integer, string, etc. ⚬ the data type determines the values that can be assigned and the operations that can be performed with the corresponding data type. • Two classification of data types in Java: ⚬ Built-in Data type ⚬ Derived Data tpye Basic Concepts • Built-in Data type - data types with built-in support in a certain language. ⚬ integers ⚬ boolean ⚬ float ⚬ character and strings • Derived data type - data types that are implementation- independent. It means that we can implement them in one way or another. ⚬ List ⚬ Array ⚬ Stack ⚬ Queue Why Data Structures • Variables store data in a program. Now, once we have several data in our program, it can get complicated, and the data gets larger each day. • Consequently, problems arise. a. Processor speed - To handle large data, high-speed processing is needed. b. Data Search - Consider a company with 1,000 employees. If our system needs to search for employee data, it needs to search through at most 1,000 employee data every time. This situation would result in slowing down the search process. Why Data Structures c. Multiple requests - If billions of users are searching the data simultaneously on a web server, then there could be a chance that a server can fail during that process. • We need some mechanism for storing and organizing that data to solve problems. What is Data Structure • data structure - a special format for organizing and storing data in a computer’s memory so that it can be retrieved quickly for processing. ⚬ Think of a computer program as a library. • The choice of data structures will also depend on their advantages and disadvantages. How to classify data structures • We can classify data structures in two types: ⚬ Linear data structure - we can access elements in sequential order.
⚬ Non-linear or hierarchical data structures - elements of
this data are stored/accessed in a non-linear order. How to classify data structures
⚬ Non-linear or hierarchical data structures - elements of
this data are stored/accessed in a non-linear order. What is algorithm? • Algorithm - a step by step solution to a problem. • We implement them through methods (Java Language) or functions (C Language). • To get a problem solved, we want not only an algorithm but also an efficient algorithm. • Run time complexity - the time taken to execute an algorithm • Space complexity - the memory it consumes/use at run time Why study algorithms? • We can use several distinct algorithms for the same problem to process a data structure. • We must choose the best one of the available algorithms. • The best algorithm is the one that balances the two factors of run time and space complexity. • We generally prioritize the time complexity than its memory complexity. • Memory is getting cheaper and computers have more memory today. Role of algorithms in data structures • Algorithms manipulate the data in the data structures in various ways. We may use several algorithms in different operations in data structures. • Basic operations that we can do in a data structure ⚬ Traverse ⚬ Insert ⚬ Delete ⚬ Search ⚬ Merge ⚬ Sort Applications of Data Structures and Algorithms • Social Media Platforms • Navigation and Maps • Operating Systems • Banking Systems Any Questions?