IT 207 – Data Structures and Algorithms
Introduction to Data Structures and Algorithms
Data is a collection of numbers, symbols or characters. It is raw and
unorganized.
Information an organized collection of data that is arranged meaningfully.
Data Structures is about how data can be stored in different structures.
Algorithms are about how to solve different problems, often by searching
through and manipulating data structures.
What are Data Structures?
Data structures give us the possibility to manage large amounts of data
efficiently for uses such as large databases and internet indexing services.
Data structures are essential ingredients in creating fast and powerful
algorithms. They help in managing and organizing data, reduce complexity,
and increase efficiency.
Real world applications example:
-Dictionary(stored alphabetically)
-Supermarket(stored categorically)
-Map(stored as coordinates)
In Computer Science there are two different kinds of data structures.
Primitive Data Structures are basic data structures provided by
programming languages to represent single values, such as integers,
floating-point numbers, characters, and booleans.
Abstract Data Structures are higher-level data structures that are built
using primitive data types and provide more complex and specialized
operations. Some common examples of abstract data structures include
arrays, linked lists, stacks, queues, trees, and graphs.
What are Algorithms?
An algorithm is a set of step-by-step instructions to solve a given problem or
achieve a specific goal.
Algorithms are fundamental to computer programming as they provide step-
by-step instructions for executing tasks. An efficient algorithm can help us to
find the solution we are looking for, and to transform a slow program into a
faster one.
By studying algorithms, developers can write better programs.
Algorithm Characteristics:
Input – o or more Inputs
Output – 1 or More Outputs
Unambiguity- Clear and Simple
Finiteness- Limited Instructions
Effectiveness- Impact of every step
Data Structures together with
Algorithms
Data structures and algorithms (DSA) go hand in hand. A data structure is
not worth much if you cannot search through it or manipulate it efficiently
using algorithms, and the algorithms in this tutorial are not worth much
without a data structure to work on.
DSA is about finding efficient ways to store and retrieve data, to perform
operations on data, and to solve specific problems.
By understanding DSA, you can:
Decide which data structure or algorithm is best for a given situation.
Make programs that run faster or use less memory.
Understand how to approach complex problems and solve them in a
systematic way.
Where is Data Structures and
Algorithms Needed?
Data Structures and Algorithms (DSA) are used in virtually every software
system, from operating systems to web applications:
For managing large amounts of data, such as in a social network
or a search engine.
For scheduling tasks, to decide which task a computer should do
first.
For planning routes, like in a GPS system to find the shortest path
from A to B.
For optimizing processes, such as arranging tasks so they can be
completed as quickly as possible.
For solving complex problems: From finding the best way to pack
a truck to making a computer 'learn' from data.
DSA is fundamental in nearly every part of the software world:
Operating Systems
Database Systems
Web Applications
Machine Learning
Video Games
Cryptographic Systems
Data Analysis
Search Engines
DSA Simple Algorithm
Fibonacci Numbers
The Fibonacci numbers are named after a 13th century Italian
mathematician known as Fibonacci.
The two first Fibonacci numbers are 0 and 1, and the next Fibonacci number
is always the sum of the two previous numbers, so we get 0, 1, 1, 2, 3, 5, 8,
13, 21, ...
Implementation Using a For Loop
It can be a good idea to list what the code must contain or do before
programming it:
Two variables to hold the previous two Fibonacci numbers
A for loop that runs 18 times
Create new Fibonacci numbers by adding the two previous ones
Print the new Fibonacci number
Update the variables that hold the previous two fibonacci numbers
public class Main {
public static void main(String[] args) {
int prev2 = 0;
int prev1 = 1;
[Link](prev2);
[Link](prev1);
for(int fibo = 0; fibo < 18; fibo++) {
int newFibo = prev1 + prev2;
[Link](newFibo);
prev2 = prev1;
prev1 = newFibo;