[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-685750-105":59,"doc-detail-685750-en":130,"doc-similar-685750":148},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","assignment-2-graph-adjacency-list-and-topological-interval-algorithms","Assignment 2 - Graph Adjacency List and Topological Interval Algorithms","","Assignment 2 answers three questions about graph representations and algorithms. It explains storing a graph using an adjacency list (linked representation), including pseudocode and analysis of space usage in terms of vertices and edges. It then describes computing in-degrees and using a queue to produce a topological order in a directed acyclic graph, with runtime reasoning and an example output. Finally, it presents an interval-based method: generating intervals per node via reverse topological processing and merging interval sequences using five cases, with a worked example merge process.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":20,"@type":76,"position":81},"https://docshare.wps.com/document/exam/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/assignment-2-graph-adjacency-list-and-topological-interval-algorithms/685750/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/assignment-2-graph-adjacency-list-and-topological-interval-algorithms/685750.png","ImageObject",300,407,{"name":92,"@type":93},"Miles","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-20","2026-11-07",true,{"@type":102,"interactionType":103,"userInteractionCount":39},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"How does the adjacency list represent graph G?","Question",{"text":112,"@type":113},"It uses an array Adj of |V| lists, with Adj[u] containing every vertex v such that there is an edge (u, v) in E. Each list corresponds to neighbors of one vertex.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"What is the queue-based algorithm for a directed acyclic graph described in Question 2?",{"text":117,"@type":113},"Initialize in-degree for each vertex, enqueue all vertices with in-degree 0, then repeatedly dequeue a vertex, increment visited count, decrease in-degrees of its neighbors, and enqueue any neighbor whose in-degree becomes 0. The visited count must equal the number of DAG vertices.",{"name":119,"@type":110,"acceptedAnswer":120},"How are interval sequences generated and merged in Question 3?",{"text":121,"@type":113},"For each node, an interval is generated and a topological order is produced. Interval sequences are built along the reverse of the topological order by merging children intervals with the node’s own interval. The merge uses five cases to handle how one interval sequence overlaps or covers elements, producing a topologically sorted result.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},685750,1794017503,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":19,"category_name":20,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":39,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":39,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":129,"read_time":46,"preview_page_count":8,"preview_urls":143},13056703019404,"https://ap-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","Answer to Question 1  \nGraph G has five vertices: v 1, v2, v3, v4, and v5. Adjacency list can be used in the linked representation to store graph G.  \nAlgorithm to store the graph in the form of a Linked list in the memory:  \n• Adjacency graph representation of a graph 􀜩 = (􀜸, 􀜧), where V is the number of vertices and E is the number of edges, consists of an array Adj of |V| lists.  \n• Adj consists of one list per vertex.  \n• The adjacency list, for each 􀝑 ∈ 􀜸 , 􀜣􀝀􀝆 [􀝑] contains all the vertices v such that there is an edge (􀝑, 􀝒) ∈ 􀜧 . This means, 􀜣􀝀􀝆 [􀝑] consists of all the vertices adjacent to u in G.  \nPseudocode:  \n\\#Initialize an empty dictionary graph = {};  \nAdd_edge(u, v):  \nif u in graph { graph[u].append(v); } \\#add v to list of neighbors for u  \nelse { graph[u] = [v]; } \\#create a new list with v as the first neighbor Add_edge(V1, V2);  \nAdd_edge(V1, V3);  \nAdd_edge(V1, V4);  \nAdd_edge(V1, V5);  \nAdd_edge(V2, V3) ;  \nAdd_edge(V2, V4);  \nAdd_edge(V2, V5);  \nAdd_edge(V3, V4);  \nAdd_edge(V3, V5);  \nAdd_edge(V4, V5);  \nAdjacency lists may also be implemented with pointers to the vertices. The adjacency lists represent the edges ofa graph. In the directed graph above, G, the sum of the lengths ofall theadjacency lists is |E|, since an edge of the form (u, v) is represented by having v appear in Adj[u] . The space complexity of the above algorithm is 􀟠 (􀜸 + 􀜧) .  \nAdjacency List Representation:  \nV1  \nV 2  \nV 3  \nV 4  \nV 5  \nAnswer to Question 2  \nThe degree of a vertex in a directed graph is its in-degree plus its out-degree. In-degree is the number of incoming edges and out-degree is the number of outgoing edges ofa vertex in a graph. Queue data structure is used that follows first-in-first-out method.  \nAlgorithm idea:  \nStep 1: Compute and initialize the in-degree for each vertex present in the Directed Acyclic Graph with number of visited nodes = 0.  \nStep 2: Find all the vertices with in-degree = 0 and add them into a queue (perform enqueue operation) .  \nStep 3: Remove a vertex from the queue (perform dequeue operation) and then perform the following –  \n1. Increment the count of visited nodes by 1.  \n2. For all the neighboring nodes, decrease in-degree by 1.  \n3. Check if in-degree of neighboring nodes are reduced to zero, then add it to the queue (perform enqueue operation) .  \nStep 4: Repeat step 3 until the queue is empty.  \nThe count of the visited nodes must be equal to the number of nodes in the directed acyclic graph.  \nExample :  \nOutput: 0 3 4 1 2  \nAnalysis:  \nSince the graph is acyclic, there must exist a vertex with in-degree = 0 and a vertex with outdegree = 0.  \nWe need a list for each vertex (in-degree) . The construction of this linked list can be done in 􀜱 (|􀜸| + |􀜧|) time. This means, Step 1, calculation of each in-degree can be done in  \n􀜱 (|􀜸| + |􀜧|) .The enqueue and dequeue operations can be done in constant time 􀜱 (1) and we have to do this for each vertex at least once. So, total time for queueing is 􀜱 (􀜸) . The insertion and deletion of the doubly linked list can be done at 􀜱 (1) . We must perform this for each child of each vertex at least one, so it has to be done |E| times. At each step we are outputting an element with in-degree = 0, with respect to all the vertices that had not been finished.  \nTherefore, the total runtime is 􀜱 (|􀜸| + |􀜧|) .  \nAnswer to Question 3  \nAlgorithm:  \nStep 1: Explore G and generate an interval 􀜫􀯩 : [􀝀 (􀝒), 􀝂 (􀝒)] for each node 􀝒 .  \nStep 2: Generate a topological order of G.  \nStep 3: Generate an interval sequence for each node 􀝒 along the reverse of the topological order as follows:  \nLet 􀝒1, 􀝒2,…, 􀝒􀯞 be the children of 􀝒 .  \nLet 􀜵􀯜 be the interval sequence generated for 􀝒􀯜 (􀝅 = 1,…, 􀝇) .  \nMerge 􀜵1, 􀜵2,…, 􀜵􀯞 and 􀜫􀯩 to generate 􀜵􀯩 .  \n[1,10] [2,9] [7,8] [3,6] [4,5]  \nMerge Operation of two interval sequences 􀜵1 and 􀜵2 :-  \nLet 􀜵1 = [􀜽1, 􀜾 1][􀜽2, 􀜾 2] … [􀜽􀯟 , 􀜾 􀯟] and 􀜵2 = [􀜿1, 􀝀 1][􀜿2, 􀝀 2] … [􀜿􀯞 , 􀝀 􀯞]  \nMerge 􀜵1 and 􀜵2 to generate:  \n􀜵 = [􀝔1, 􀝕1][􀝔2, 􀝕2]","cbCaiddHBCVkVihH","https://ap.wps.com/l/cbCaiddHBCVkVihH","pdf",325660,"English","# Answer to Question 1\n## Adjacency list representation and pseudocode\n## Space complexity discussion\n# Answer to Question 2\n## In-degree plus out-degree and queue-based topological process\n## Algorithm steps and runtime analysis\n# Answer to Question 3\n## Interval generation using reverse topological order\n## Merge operation and five cases\n## Worked example merge traces","[{\"question\":\"How does the adjacency list represent graph G?\",\"answer\":\"It uses an array Adj of |V| lists, with Adj[u] containing every vertex v such that there is an edge (u, v) in E. Each list corresponds to neighbors of one vertex.\"},{\"question\":\"What is the queue-based algorithm for a directed acyclic graph described in Question 2?\",\"answer\":\"Initialize in-degree for each vertex, enqueue all vertices with in-degree 0, then repeatedly dequeue a vertex, increment visited count, decrease in-degrees of its neighbors, and enqueue any neighbor whose in-degree becomes 0. The visited count must equal the number of DAG vertices.\"},{\"question\":\"How are interval sequences generated and merged in Question 3?\",\"answer\":\"For each node, an interval is generated and a topological order is produced. Interval sequences are built along the reverse of the topological order by merging children intervals with the node’s own interval. The merge uses five cases to handle how one interval sequence overlaps or covers elements, producing a topologically sorted result.\"}]","Assignment 2 - Graph Adjacency List and Topological Interval Algorithms | PDF",[144],{"page_no":8,"url":145,"width":146,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/31aa24f27137568d3e616d5298157975.webp",983,1272,{"list":149,"token":66},[150,156,162,168,174,180,185,192,198,204],{"doc_id":151,"doc_title":152,"file_type":137,"home_preview_img_url":153,"slug":154,"view_count":39,"category_name":20,"create_tm":155},480632,"Identifying a Figure from its Attributes - Figure Attributes Quiz","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926450841/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=Wvdm0V%2FE6D8Ts0yRyCmjoNyIAVQ%3D","identifying-a-figure-from-its-attributes-figure-attributes-quiz",1790795316,{"doc_id":157,"doc_title":158,"file_type":137,"home_preview_img_url":159,"slug":160,"view_count":52,"category_name":20,"create_tm":161},481324,"Characteristics of 3d Shapes - Practice - Faces, Vertices, and Edges","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926757023/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=8sId%2BJNTw4H4d%2B6r8xlW4NczdBA%3D","characteristics-of-3d-shapes-practice-faces-vertices-and-edges",1790796542,{"doc_id":163,"doc_title":164,"file_type":137,"home_preview_img_url":165,"slug":166,"view_count":44,"category_name":20,"create_tm":167},481321,"Characteristics of 3d Shapes - Use the diagram to determine faces, vertices and edges - Answer Key","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926756998/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=62mIwimZe9ASvOVbctjNgvOjTMo%3D","characteristics-of-3d-shapes-use-the-diagram-to-determine-faces-vertices-and-edges-answer-key",1790796535,{"doc_id":169,"doc_title":170,"file_type":137,"home_preview_img_url":171,"slug":172,"view_count":39,"category_name":20,"create_tm":173},481317,"Characteristics of 3D Shapes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926453215/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=whW2RBBavMiQAlW2ovmp0WI5pF8%3D","characteristics-of-3d-shapes",1790796531,{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":179,"category_name":20,"create_tm":173},481319,"Characteristics of 3d Shapes - Determine faces, vertices, and edges","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926453216/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=pBWtm%2BtadzaaLpPs%2BbX0eU6q54Y%3D","characteristics-of-3d-shapes-determine-faces-vertices-and-edges",17,{"doc_id":181,"doc_title":182,"file_type":137,"home_preview_img_url":183,"slug":184,"view_count":52,"category_name":20,"create_tm":173},481318,"Characteristics of 3d Shapes - Worksheet Answers","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926453214/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=msFACUDv7acPzSVclR7WoWLRHSA%3D","characteristics-of-3d-shapes-worksheet-answers",{"doc_id":186,"doc_title":187,"file_type":137,"home_preview_img_url":188,"slug":189,"view_count":190,"category_name":20,"create_tm":191},636035,"List of Geometric Shapes - 3D Properties","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229969974656/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=lbEkgPO4Pd8vKmQpSDYT0aOzEbU%3D","list-of-geometric-shapes-3d-properties",12,1792677378,{"doc_id":193,"doc_title":194,"file_type":137,"home_preview_img_url":195,"slug":196,"view_count":52,"category_name":20,"create_tm":197},657283,"Algorithms and flowcharts - Chapter 1 - Learning Intentions and Practical Tasks","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975408582/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=Rl3jx9w7oFSoQIe%2F2E2ur02SiVw%3D","algorithms-and-flowcharts-chapter-1-learning-intentions-and-practical-tasks",1792976874,{"doc_id":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":29,"category_name":20,"create_tm":203},657382,"Feynman Diagrams and the S-Matrix and Outer Space - Summer 2020 - Exercise 6","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975441795/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=Tpthw%2FFS%2BtviPGZV2YoVC794Y0A%3D","feynman-diagrams-and-the-s-matrix-and-outer-space-summer-2020-exercise-6",1792978315,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":209,"category_name":20,"create_tm":210},481270,"Characteristics of 3D Shapes - Solve Each Problem","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926756522/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796168519&Signature=2RrqTveAbxT%2BC18SzOCffXre%2Buk%3D","characteristics-of-3d-shapes-solve-each-problem-481270",14,1790796444]