University of the People**We aren't endorsed by this school
Course
CS 3304
Subject
Computer Science
Date
Jan 9, 2025
Pages
4
Uploaded by Stiven094
Learning Journal for Unit 3: Graphs (Part 1)What I Did and How I Did ItIn Unit 3, I explored various aspects of graph theory, including graph terminology, representations, traversals, and greedy algorithms. I implemented graph data structures and focused on traversals such as Depth-First Search (DFS) and Breadth-First Search (BFS). Using Python, I represented graphs with adjacency lists and matrices, as highlighted in the examples and materials I reviewed (Techie Delight, 2022; W3Schools, n.d.). For traversals, I wrote code to explore vertices recursively with DFS and iteratively using a queue for BFS. Additionally, I delved into topological sorting and analyzed scenarios where greedy algorithms like graph traversals offer efficient solutions.Reactions to What I DidWorking on this unit felt both challenging and rewarding. Implementing DFS and BFS deepened my understanding of how algorithms behave under different graph structures, such as cyclic, acyclic, directed, and weighted graphs (GeeksforGeeks, 2024; Dey, n.d.). The step-by-step logic required for writing recursive and iterative code was initially daunting, but breaking the tasks into smaller sub-problems helped simplify the process.Feelings and AttitudesAt the beginning of the unit, I felt overwhelmed by the complexity of graph representations and their applications. However, as I progressed, my confidence grew. The realization that graph theory underpins many real-world systems, such as social networks and navigation tools, made the topic fascinating and highly relevant to my studies.What I Learned
I learned how to:Differentiate between graph types, including directed, undirected, weighted, and unweighted graphs (Techie Delight, 2022; W3Schools, n.d.).Implement graphs using adjacency matrices and adjacency lists, understanding their trade-offs in terms of memory and performance.Traverse graphs using DFS and BFS, recognizing their applications and greedy characteristics (GeeksforGeeks, 2024; Dey, n.d.).Apply DFS for topological sorting and cycle detection, and BFS for shortest path discovery in unweighted graphs.Recognize the importance of marking nodes as visited to prevent infinite loops, especially in cyclic graphs.What Surprised Me or Caused Me to Wonder?I was surprised by the versatility of BFS and DFS. For example, using BFS to solve real-world problems like web crawling felt innovative. The idea that a graph traversal could help find the shortest path in social networks or analyze connections two levels deep was eye-opening. Similarly, the recursive nature of DFS, resembling tree traversal, intrigued me with its elegance yet practical complexity in implementation.Challenges Faced and Their ReasonsThe most challenging part was implementing DFS and BFS correctly for graphs with cycles. Ensuring that I handled edge cases, such as disconnected components and loops, required careful attention to detail. Debugging recursive DFS was particularly difficult because of stack overflow
errors when I forgot to mark nodes as visited. Additionally, understanding topological sorting in directed acyclic graphs (DAGs) took effort due to its abstract nature.Skills and Knowledge GainedI gained technical skills in graph data structures, traversal algorithms, and their implementation in Python. I also enhanced my problem-solving skills by applying theoretical concepts to practical problems, such as finding the shortest path or detecting cycles in a graph. My ability to think systematically improved as I learned to break down algorithms into manageable steps.Realizations About Myself as a LearnerI realized that I learn best when I visualize problems. Drawing graphs and simulating algorithms on paper helped me grasp abstract concepts like adjacency matrices and lists. I also discovered that hands-on coding solidifies my understanding more effectively than theoretical reading alone.Applying Concepts to My ExperienceThe concepts learned in this unit have practical applications in my computer science studies and future projects. For instance, I can use BFS for optimizing social network analysis or shortest path problems in navigation systems. Additionally, understanding DFS's role in topological sorting is invaluable for dependency resolution in software or task scheduling.
ReferencesDey, A. (n.d.). Breadth first search (BFS). The Algorists. Retrieved from https://www.thealgorists.com/Algo/GraphTheory/BFSGeeksforGeeks. (2024, November 26). Depth first search or DFS for a graph. Retrieved from https://www.geeksforgeeks.org/depth-first-search-or-dfs-for-a-graph/Techie Delight. (2022). Terminology and representations of graphs. Retrieved from https://www.techiedelight.com/terminology-and-representations-of-graphs/W3Schools. (n.d.). DSA Graphs. Retrieved from https://www.w3schools.com/dsa/dsa_theory_graphs.php