0% found this document useful (0 votes)
9 views6 pages

DS2

The document provides an overview of data structures, including linear (arrays, linked lists, stacks, queues, deques) and non-linear structures (trees, graphs, heaps, hash tables). It discusses tree and graph theory, detailing types of trees, traversal algorithms, and various graph types and algorithms. Additionally, it covers computational geometry, network models (OSI and TCP/IP), types of networks, topologies, and their applications in fields like computer graphics, robotics, and cybersecurity.

Uploaded by

jeuspunongbayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

DS2

The document provides an overview of data structures, including linear (arrays, linked lists, stacks, queues, deques) and non-linear structures (trees, graphs, heaps, hash tables). It discusses tree and graph theory, detailing types of trees, traversal algorithms, and various graph types and algorithms. Additionally, it covers computational geometry, network models (OSI and TCP/IP), types of networks, topologies, and their applications in fields like computer graphics, robotics, and cybersecurity.

Uploaded by

jeuspunongbayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Data Structures: Linear and Non-Linear


A. Linear Data Structures

A linear data structure organizes elements sequentially, where each element has a unique
successor and predecessor (except the first and last elements).

Examples:

1.​ Arrays – Fixed-size, contiguous memory storage.​


Example: int arr[5] = {1, 2, 3, 4, 5};​

2.​ Linked Lists – Dynamic memory allocation with pointers.​


Example: A linked list of integers: 1 -> 2 -> 3 -> 4 -> 5​

3.​ Stacks – LIFO (Last In, First Out) principle.​


Example: A stack storing items: Push 1, then push 2, then pop returns 2.​

4.​ Queues – FIFO (First In, First Out) principle.​


Example: A queue of people waiting: Person 1 -> Person 2 -> Person 3 (Person 1 exits
first).​

5.​ Deques – A double-ended queue that supports insertions and deletions from both ends.​

B. Non-Linear Data Structures

A non-linear data structure does not store data in a sequential manner. Instead, it forms
hierarchical or interconnected relationships.

Examples:

1.​ Trees – Hierarchical structures with parent-child relationships.​

2.​ Graphs – Nodes connected by edges.​

3.​ Heaps – Specialized tree-based structures for priority queues.​

4.​ Hash Tables – Key-value data storage for fast lookups.​


2. Trees and Graph Theory
A. Trees

A tree is a hierarchical data structure that consists of nodes connected by edges. It is a special
type of graph with no cycles.

Key Characteristics:

●​ A tree with n nodes has n-1 edges.​

●​ One node is designated as the root.​

●​ Each node (except the root) has exactly one parent.​

●​ Nodes can have zero or more child nodes.​

Types of Trees:

1.​ Binary Tree – Each node has at most two children.​

2.​ Binary Search Tree (BST) – A binary tree where the left subtree contains smaller
values and the right subtree contains larger values.​

3.​ Balanced Tree – A tree where the height is minimized (e.g., AVL Tree, Red-Black Tree).​

4.​ Heap – A complete binary tree used in priority queues.​

5.​ Trie – Used for string searching (e.g., in dictionaries, autocomplete features).​

Tree Traversal Algorithms:

1.​ Depth-First Search (DFS)​

○​ Preorder (Root → Left → Right)​

○​ Inorder (Left → Root → Right)​

○​ Postorder (Left → Right → Root)​

2.​ Breadth-First Search (BFS)​


○​ Also known as Level Order Traversal​

B. Graph Theory

A graph is a collection of nodes (vertices) and connections (edges). Graphs can be used to
model relationships in networks, social media, and navigation systems.

Types of Graphs:

1.​ Directed Graph (Digraph) – Edges have a direction.​

2.​ Undirected Graph – Edges have no direction.​

3.​ Weighted Graph – Edges have weights (e.g., representing distances or costs).​

4.​ Connected Graph – A path exists between every pair of nodes.​

5.​ Cyclic and Acyclic Graphs – Acyclic graphs have no cycles (e.g., Trees are acyclic
graphs).​

Graph Algorithms:

1.​ Depth-First Search (DFS) – Explores as far as possible along each branch before
backtracking.​

2.​ Breadth-First Search (BFS) – Explores all neighbors before moving deeper.​

3.​ Dijkstra’s Algorithm – Finds the shortest path in a weighted graph.​

4.​ Kruskal’s and Prim’s Algorithm – Used to find the Minimum Spanning Tree (MST).​

5.​ Floyd-Warshall Algorithm – Computes shortest paths between all pairs of vertices.​

Example:

For a graph G = (V, E) where V = {a, b, c, d} and E = {{a, b}, {a, c}, {b,
c}, {c, d}}:

●​ Vertices: a, b, c, d​
●​ Edges: {a, b}, {a, c}, {b, c}, {c, d}​

For DFS, starting from vertex a, you would visit the vertices as a -> b -> c -> d.

3. Computational Geometry
A. Basics of Computational Geometry

Computational Geometry is a branch of computer science that focuses on designing algorithms


to solve geometric problems.

Key Characteristics:

●​ Deals with geometric objects in 2D and 3D space.​

●​ Uses mathematical techniques to solve geometric problems.​

Types of Computational Geometry:

1.​ Combinatorial Computational Geometry – Studies geometric objects and their


arrangements.​

2.​ Numerical Computational Geometry – Involves numerical techniques for solving


geometric problems.​

B. Applications:

●​ Computer Graphics & Gaming – Collision detection, 3D rendering.​

●​ Robotics & Path Planning – Obstacle avoidance, self-driving cars.​

●​ GIS (Geographic Information Systems) – Mapping, shortest path analysis.​

●​ CAD (Computer-Aided Design) – 3D object modeling.​

●​ Image Processing – Shape recognition, object detection.​

Example:
●​ Convex Hull Algorithm:​
A convex hull is the smallest convex polygon that contains all the points. It is important
in areas like robotics and pathfinding.​

○​ For a set of points in 2D, you can use the Graham Scan algorithm to find the
convex hull in O(n log n) time.​

4. Network Models
A. Basics of Network Models

A Network Model defines how data is structured, transmitted, and managed in a computer
network. The two primary models are:

1.​ OSI (Open Systems Interconnection) Model – Standardized into 7 layers.​

2.​ TCP/IP Model – Practical model used for the Internet.​

OSI Model (7 Layers):

1.​ Physical Layer – Deals with raw data transmission.​

2.​ Data Link Layer – Error detection, MAC addressing.​

3.​ Network Layer – IP addressing, routing.​

4.​ Transport Layer – End-to-end communication (TCP, UDP).​

5.​ Session Layer – Manages sessions between devices.​

6.​ Presentation Layer – Data formatting, encryption.​

7.​ Application Layer – Web services, email, file transfers.​


B. Types of Networks

1.​ PAN (Personal Area Network) – Small-scale, like Bluetooth, smart devices.​

2.​ LAN (Local Area Network) – Office, school networks.​

3.​ MAN (Metropolitan Area Network) – Covers cities, campuses.​

4.​ WAN (Wide Area Network) – Internet-scale networking.​

Network Topologies:

1.​ Bus – Single communication line.​

2.​ Star – Central hub with connected devices.​

3.​ Ring – Closed-loop structure.​

4.​ Mesh – Every device is interconnected.​

5.​ Hybrid – Combination of different topologies.​

C. Applications of Network Models

●​ Internet Communication – Web browsing, video conferencing.​

●​ Cloud Computing – Remote data access and storage.​

●​ Online Banking – Secure financial transactions.​

●​ IoT (Internet of Things) – Smart home automation.​

●​ Cybersecurity – Firewalls, VPNs for secure communication.

You might also like