DSA Explorer
QuicksortMerge SortBubble SortInsertion SortSelection SortHeap SortCounting SortRadix SortBucket SortShell SortTim SortCocktail Shaker SortComb SortGnome SortPancake SortPatience SortCycle SortStrand SortWiggle Sort (Wave Sort)Bead Sort (Gravity Sort)Binary Insertion SortBitonic SortBogo Sort (Stupid Sort)Stooge SortOdd-Even Sort (Brick Sort)Pigeonhole SortIntro Sort (Introspective Sort)Tree Sort (BST Sort)Dutch National Flag (3-Way Partitioning)
Binary SearchLinear SearchJump SearchInterpolation SearchExponential SearchTernary SearchFibonacci SearchQuick Select (k-th Smallest)Median of Medians (Deterministic Select)Hill climbingSimulated AnnealingTabu SearchBinary Tree DFS SearchSentinel Linear SearchDouble Linear SearchTernary Search (Unimodal Function)Search in 2D Matrix
Binary Search Tree (BST)StackQueueHash Table (Hash Map)Heap (Priority Queue)Linked ListTrie (Prefix Tree)Binary TreeTrie (Prefix Tree)Floyd's Cycle Detection (Tortoise and Hare)Merge Two Sorted Linked ListsCheck if Linked List is PalindromeFind Middle of Linked ListBalanced Parentheses (Valid Parentheses)Next Greater ElementInfix to Postfix ConversionMin Stack (O(1) getMin)Largest Rectangle in HistogramDaily Temperatures (Monotonic Stack)Evaluate Reverse Polish NotationInfix Expression Evaluation (Two Stacks)Min Heap & Max HeapSliding Window MaximumTrapping Rain WaterRotate Matrix 90 DegreesSpiral Matrix TraversalSet Matrix ZeroesHash Table with ChainingOpen Addressing (Linear Probing)Double HashingCuckoo Hashing
Depth-First Search (DFS)Breadth-First Search (BFS)Dijkstra's AlgorithmFloyd-Warshall AlgorithmKruskal's AlgorithmPrim's AlgorithmTopological SortA* Pathfinding AlgorithmKahn's Algorithm (Topological Sort)Ford-Fulkerson Max FlowEulerian Path/CircuitBipartite Graph CheckBorůvka's Algorithm (MST)Bidirectional DijkstraPageRank AlgorithmBellman-Ford AlgorithmTarjan's Strongly Connected ComponentsArticulation Points (Cut Vertices)Find Bridges (Cut Edges)Articulation Points (Cut Vertices)Finding Bridges (Cut Edges)
0/1 Knapsack ProblemLongest Common Subsequence (LCS)Edit Distance (Levenshtein Distance)Longest Increasing Subsequence (LIS)Coin Change ProblemFibonacci Sequence (DP)Matrix Chain MultiplicationRod Cutting ProblemPalindrome Partitioning (Min Cuts)Subset Sum ProblemWord Break ProblemLongest Palindromic SubsequenceMaximal Square in MatrixInterleaving StringEgg Drop ProblemUnique Paths in GridCoin Change II (Count Ways)Decode WaysWildcard Pattern MatchingRegular Expression MatchingDistinct SubsequencesMaximum Product SubarrayHouse RobberClimbing StairsPartition Equal Subset SumKadane's Algorithm (Maximum Subarray)
A* Search AlgorithmConvex Hull (Graham Scan)Line Segment IntersectionCaesar CipherVigenère CipherRSA EncryptionHuffman CompressionRun-Length Encoding (RLE)Lempel-Ziv-Welch (LZW)Canny Edge DetectionGaussian Blur FilterSobel Edge FilterHarris Corner DetectionHistogram EqualizationMedian FilterLaplacian FilterMorphological ErosionMorphological DilationImage Thresholding (Otsu's Method)Conway's Game of LifeLangton's AntRule 30 Cellular AutomatonFast Fourier Transform (FFT)Butterworth FilterSpectrogram (STFT)
Knuth-Morris-Pratt (KMP) AlgorithmRabin-Karp AlgorithmBoyer-Moore AlgorithmAho-Corasick AlgorithmManacher's AlgorithmSuffix ArraySuffix Tree (Ukkonen's Algorithm)Trie for String MatchingEdit Distance for StringsLCS for String MatchingHamming DistanceJaro-Winkler DistanceDamerau-Levenshtein DistanceBitap Algorithm (Shift-Or, Baeza-Yates-Gonnet)Rolling Hash (Rabin-Karp Hash)Manacher's AlgorithmZ AlgorithmLevenshtein Distance

First Come First Serve (FCFS)

Algorithms
O(n) time, O(1) space
Beginner

Non-preemptive scheduling executing processes in arrival order. Simple queue-based scheduling algorithm that serves as the foundation for understanding CPU scheduling. Despite its simplicity, FCFS can suffer from the convoy effect where short processes are delayed by long-running processes ahead of them in the queue.

Prerequisites:
Queue data structure
Process concepts

Visualization

Interactive visualization for First Come First Serve (FCFS)

FCFS Scheduling:

  • • First Come First Serve
  • • Non-preemptive

Interactive visualization with step-by-step execution

Implementation

Language:
1function fcfsScheduling(processes: {id: number; arrivalTime: number; burstTime: number}[]): {avgWaitTime: number; avgTurnaroundTime: number} {
2  processes.sort((a, b) => a.arrivalTime - b.arrivalTime);
3  let currentTime = 0;
4  let totalWait = 0, totalTurnaround = 0;
5  
6  for (const p of processes) {
7    if (currentTime < p.arrivalTime) currentTime = p.arrivalTime;
8    const waitTime = currentTime - p.arrivalTime;
9    const turnaroundTime = waitTime + p.burstTime;
10    totalWait += waitTime;
11    totalTurnaround += turnaroundTime;
12    currentTime += p.burstTime;
13  }
14  
15  return {
16    avgWaitTime: totalWait / processes.length,
17    avgTurnaroundTime: totalTurnaround / processes.length
18  };
19}

Deep Dive

Theoretical Foundation

First Come First Serve (FCFS) is the simplest CPU scheduling algorithm where processes are executed in the exact order they arrive in the ready queue. It's non-preemptive, meaning once a process starts execution, it runs to completion without interruption. The algorithm maintains a FIFO (First In, First Out) queue of processes. While conceptually simple and fair in terms of arrival order, FCFS can lead to poor average waiting times due to the convoy effect, where short processes must wait for long processes that arrived earlier. The algorithm is deterministic and provides no starvation, but lacks optimization for system throughput or response time.

Complexity

Time

Best

O(n log n)

Average

O(n log n)

Worst

O(n log n)

Space

Required

O(1)

Applications

Industry Use

1

Batch processing systems in mainframes

2

Print job queues in network printers

3

Simple embedded system task scheduling

4

Background job processing

5

First-generation operating systems

6

Sequential file processing systems

Use Cases

Batch systems
Simple schedulers
Print queues

Related Algorithms

Shortest Job First (SJF)

Schedules process with shortest burst time first. Minimizes average waiting time (optimal).

Algorithms

Round Robin Scheduling

Preemptive scheduling with fixed time quantum. Each process gets equal CPU time slices.

Algorithms

Priority Scheduling

Schedules processes based on priority. Higher priority executes first. Can be preemptive or non-preemptive.

Algorithms

Quicksort

A highly efficient, in-place sorting algorithm that uses divide-and-conquer strategy. Invented by Tony Hoare in 1959, it remains one of the most widely used sorting algorithms due to its excellent average-case performance and cache efficiency.

Sorting
DSA Explorer

Master Data Structures and Algorithms through interactive visualizations and detailed explanations. Our platform helps you understand complex concepts with clear examples and real-world applications.

Quick Links

  • About DSA Explorer
  • All Algorithms
  • Data Structures
  • Contact Support

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • Code of Conduct

Stay Updated

Subscribe to our newsletter for the latest algorithm explanations, coding challenges, and platform updates.

We respect your privacy. Unsubscribe at any time.

© 2026 Momin Studio. All rights reserved.

SitemapAccessibility
v1.0.0