DSA

Cards (41)

  • Algorithm
    A finite sequence of rigorous instructions used to solve a class of specific problems or perform a computation
  • Algorithms
    • They are well-defined sequential computational techniques that accept input and produce the desired output
    • They must be accurate, stopping with the proper output for each input instance
    • They are essential tools for tasks requiring a lot of calculations or data processing
    • They can be standardized and shared among different teams or organizations, facilitating collaboration and knowledge sharing
  • Algorithm examples
    • Example 1: Algorithm to solve a specific problem or perform a computation
    • Example 2: Another algorithm demonstrating the use of algorithms
  • Asymptotic analysis
    Used to describe the running time of an algorithm as the input size increases
  • Big-O notation
    A mathematical notation used to describe the upper bound of an algorithm's running time
  • Omega notation
    Used to describe the lower bound of an algorithm's running time, representing the best-case scenario
  • Theta notation
    Used to describe the exact running time of an algorithm, representing both the upper and lower bounds
  • Factors affecting algorithm efficiency
    • Finiteness: Algorithms must conclude within a predetermined number of steps
    • Correctness: Algorithms should generate proper results regardless of the input size
    • Time Complexity: The time required for an algorithm to complete its task
    • Space Complexity: The amount of memory an algorithm requires to execute
  • Real-world programmers are constrained by the physical memory of the systems on which they intend to run their code
  • Analyzing the time and space complexity of an algorithm using asymptotic notations helps developers select the most efficient algorithm for a given problem
  • Algorithmic complexity
    The inherent difficulty of solving a problem using a specific algorithm
  • Highly complex algorithms can be computationally expensive and may not be practical for real-world applications, especially those with limited resources
  • Algorithmic complexity analysis is widely used in various domains, including computer science, operations research, and decision-making
  • Addressing the challenges of algorithmic complexity analysis requires a deep understanding of algorithms, data structures, and the specific problem context, as well as the ability to apply advanced analytical methods and techniques
  • As technology and computational power continue to evolve, the need for efficient and scalable algorithms becomes increasingly important
  • Data structure
    A specific way of organizing data in a specialized format on a computer to enable efficient information organization, processing, storage, and retrieval
  • Every application, piece of software, or program's foundation consists of two components: algorithms and data
  • Characteristics of data structures
    • They can be linear or non-linear, arranging data in sequential order or in a more complex, interconnected manner
    • They can be static (with fixed formats and sizes) or dynamic (with variable formats and sizes)
    • Time complexity and space complexity are important considerations in the design and selection of data structures
  • Algorithm
    A set of rules or instructions for solving a problem or performing a task, especially by a computer
  • Data
    Information optimized for processing and movement, stored on computers as facts and figures
  • Algorithms
    The rules and instructions that turn data into something useful to programming
  • Data structures
    • Can be linear or non-linear, arranging data in sequential order or in a more complex, interconnected manner
    • Can be static (with fixed formats and sizes) or dynamic (with variable formats and sizes)
    • Time complexity, the running time or execution time of a program, should be limited for efficient data processing
    • Space complexity, the amount of space occupied, should be minimized for proper device function
    • The relationship between related data and permissible operations on that data defines the data structure
  • Linear data structures
    Arrange data elements in a sequential order, with each element linked to the ones in front and behind it
  • Examples of linear data structures
    • Stacks
    • Arrays
    • Queues
    • Linked lists
  • Stacks
    • Linear data structures that follow the LIFO (last-in, first-out) or FILO (first-in, last-out) order
    • The main operations are "push" (insert) and "pop" (delete), which add and remove elements from the top of the stack, respectively
  • Stacks
    • Have applications in web browser history, undo/redo functionality, notification management, and more
    • Are commonly implemented using arrays or linked lists, and their time complexity for push and pop operations is O(1)
    • Are used in various algorithms and data structures, such as expression evaluation, function calls, and depth-first search (DFS) in graphs
  • Queues
    • Linear data structures that follow the FIFO (first-in, first-out) order
    • The main operations are "enqueue" (insert at the rear) and "dequeue" (delete from the front)
  • Queues
    • Have applications in task scheduling, batch processing, buffering, network protocols, and printer management
    • Are commonly implemented using arrays or linked lists, and their time complexity for enqueue and dequeue operations is O(1)
    • Are used in various algorithms and data structures, such as breadth-first search (BFS) in graphs and job scheduling in operating systems
  • Arrays
    • Linear data structures that store a collection of similar data types in contiguous memory locations
    • Can be one-dimensional or multi-dimensional, allowing for efficient storage and manipulation of data
  • Arrays
    • Have applications in sorting, searching, matrix operations, stacks, queues, and graph representation
    • The time complexity for array operations, such as accessing, inserting, and deleting elements, depends on the size of the array and the specific operation being performed
    • Are widely used in various algorithms and data structures due to their simple implementation and efficient memory utilization
  • Linked lists
    • Linear data structures that store data elements in separate memory locations, connected by pointers
    • Can be singly linked, doubly linked, or circular, depending on the direction and nature of the links between nodes
    • The first element is known as the "head," and the last element is the "tail" or "null"
  • Linked lists
    • Allow for dynamic memory allocation, efficient insertion and deletion operations, and the representation of complex data structures like stacks and queues
    • Have applications in memory allocation, arithmetic operations on large integers, graph representation, and file systems
  • Non-linear data structures

    Characterized by the random arrangement of data elements, with each element connected to one or more other elements
  • Types of non-linear data structures
    • Trees
    • Graphs
  • Tree data structures
    • Hierarchical in nature, with a root node and child nodes organized in a tree-like structure
    • Each node can have one or more child nodes, but only one parent node (except for the root node)
  • Tree data structures
    • Have applications in file systems, search algorithms (e.g., binary search trees), expression parsing, and decision-making processes
    • Various types of trees exist, such as binary trees, binary search trees, AVL trees, and B-trees, each with its own characteristics and use cases
  • Graph data structures
    • Consist of nodes (vertices) connected by edges, representing relationships between data elements
    • Can be directed (with one-way edges) or undirected (with two-way edges), and can also be weighted (with assigned edge values)
  • Graph data structures
    • Have applications in social network analysis, route planning, recommendation systems, and various optimization problems
    • Are often used to represent complex relationships and interconnections between data elements, making them a powerful tool in data analysis and problem-solving
  • Data types
    • Boolean
    • Integer
    • Floating-point Numbers
    • Fixed-point Numbers
    • Pointers
    • Character
    • String
  • Applications of data structures
    • Storing Data
    • Resource and Service Management
    • Data Exchange
    • Ordering and Sorting
    • Indexing
    • Searching
    • Scalability