Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Pro Blog
  • Users
  • Groups
  • Unsolved
  • Solved
Collapse
Secnto AI
  1. Secnto AI
  2. Categories
  3. Virtual University
  4. CS502 - Fundamentals of Algorithms
  5. CS502 Assignment No. 02 Solution and Discussion
CS502 Quiz 2 Solution and Discussion
M
The ________ given by DFS allow us to determine whether the graph contains any cycles. CS502 Order Time stamps Page 130 BFS traversing Topological sort [image: kWtCijV.png] 8.1.5 DFS - Cycles The time stamps given by DFS allow us to determine a number of things about a graph or digraph. For example, we can determine whether the graph contains any cycles. We do this with the help of the following two lemmas.
CS502 - Fundamentals of Algorithms
CS502 Assignment 1 Solution and Discussion
cyberianC
Re: CS502 Assignment No. 01 Solution and Discussion
CS502 - Fundamentals of Algorithms
The Huffman algorithm finds for?
M
► Optimal ► Non-optimal ► Exponential ► Polynomial
CS502 - Fundamentals of Algorithms
What is generally true of Adjacency List and Adjacency Matrix representations of graphs?
M
In graph theory and computer science, an adjacency list is a collection of unordered lists used to represent a finite graph. Each list describes the set of neighbors of a vertex in the graph. This is one of several commonly used representations of graphs for use in computer programs.
CS502 - Fundamentals of Algorithms
CS502 Handouts
M
Fundamentals of Algorithms - CS502 Handouts.pdf
CS502 - Fundamentals of Algorithms
CS502 GDB 1 Solution and Discussion
zareenZ
Consider that a tourist wants to travel between Karachi and Hunza cities in minimum possible span. The road map available has marked distance between each pair of adjacent cities. The time available to the tourist has limited and he/she require to find the shortest possible route between Karachi and Hunza. In the given scenario, the possible solution may be adopted from the following set of algorithms. Bellman ford’s Algorithm Flyod Warshal’s Algorithm Dijkstra's Algorithm Breadth-first-search algorithm You are required to select the possible and most reasonable algorithm for the given scenario. Support you answer with solid reasons.
CS502 - Fundamentals of Algorithms
CS502 Assignment 3 Solution and Discussion
zareenZ
Assignment No. 03 SEMESTER Fall 2019 CS502- Fundamentals of Algorithms Total Marks: 20 Due Date: 15/01/2020 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file corrupt. • The assignment is fully or partially copied from (other student or ditto copy from handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .doc or .docx format. Uploading instructions Your submission must include: • Assignment should be in .doc or .docx format. • Save your assignment with your ID (e.g. bx180200786.doc). Assignment submission through email is NOT acceptable Objective The objective of this assignment is • To give basic knowledge and understanding of Graphs. • To develop the understanding between adjacency list and adjacency matrix representations. Note: Your answer must follow the below given specifications. • Font style: “Times New Roman” • Font color: “Black” • Font size: “12” • Bold for heading only. • Font in Italic is not allowed at all. • No formatting or bullets are allowed to use. • Your answer should be precise and to the point, avoid irrelevant detail. Lectures Covered: This assignment covers Lecture # 28 Deadline Your assignment must be uploaded/submitted at or before 15/01/2020. Assignment Statement: Everywhere we see objects and some sort of interaction between them. If we are needed to model this connection or relationship between them, the graphs is a good way to model it. A graph G = (V, E) consists of a finite set of vertices V (or nodes) and E, a binary relation on V called edges. E is a set of pairs from V. If a pair is ordered, we have a directed graph. For unordered pair, we have an undirected graph. There are two ways of representing graphs: using an adjacency matrix and using an adjacency list. Question No 01: (Marks: 10) Draw an undirected Graph for the following Adjacency list representation as given below, [image: UpPt7RI.png] Question No 02: (Marks: 10) Draw a directed graph for the following matrix format representation, [image: phVL6cO.png] =====================================Ended======================================= For any query about the assignment, contact at CS502@vu.edu.pk GOOD LUCK
CS502 - Fundamentals of Algorithms
CS502 Assignment No. 02 Solution and Discussion
zareenZ
Assignment No. 02 SEMESTER Fall 2019 CS502- Fundamentals of Algorithms Total Marks: 20 Due Date: 27/11/2019 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file corrupt. • The assignment is full or partially copied from (other student or ditto copy from handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .doc or .docx format. Uploading instructions Your submission must include: • Assignment should be in .doc or .docx format. • Save your assignment with your ID (e.g. bx180200786.doc). Assignment submission through email is NOT acceptable Objective The objective of this assignment is • To give basic knowledge and understanding of Algorithms. • To be able to design sorting algorithms. • To be able to understand and calculate the complexity of algorithms. Note: Your answer must follow the below given specifications. • Font style: “Times New Roman” • Font color: “Black” • Font size: “12” • Bold for heading only. • Font in Italic is not allowed at all. • No formatting or bullets are allowed to use. • Your answer should be precise and to the point, avoid irrelevant detail. Lectures Covered: This assignment covers Lecture # 09 - 14 Deadline Your assignment must be uploaded/submitted at or before 27/11/2019. Assignment diagram: [image: ISyleYl.png] Consider the given diagram having an unsorted array and its sorting procedure through dry run. You are required to answer the following questions. Question No 01: (Marks: 5) You are required to determine (write down the name) the algorithm being used while sorting the above given array. Question No 02: (Marks: 7) You are required to design (write) the algorithm (Only Pseudo code) determined in Question 1. Question No 03: (Marks: 8) You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 02. =====================================Ended======================================= For any query about the assignment, contact at CS502@vu.edu.pk GOOD LUCK
CS502 - Fundamentals of Algorithms
CS502 Midterm Solved Papers Mid and Final
zareenZ
Please share your current paper
CS502 - Fundamentals of Algorithms
CS502 Assignment No. 01 Solution and Discussion
zareenZ
Assignment No. 01 SEMESTER Fall 2019 CS502- Fundamentals of Algorithms Total Marks: 20 Due Date: 13/11/2019 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file corrupt. • The assignment is full or partially copied from (other student or ditto copy from handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .doc or .docx format. Uploading instructions Your submission must include: • Assignment should be in .doc or .docx format. • Save your assignment with your ID (e.g. bx180200786.doc). Assignment submission through email is NOT acceptable Objective The objective of this assignment is • To give basic knowledge and understanding of Algorithms. • To be able to design simple algorithms. • To be able to understand and calculate the complexity of algorithms. Note: Your answer must follow the below given specifications. • Font style: “Times New Roman” • Font color: “Black” • Font size: “12” • Bold for heading only. • Font in Italic is not allowed at all. • No formatting or bullets are allowed to use. • Your answer should be precise and to the point, avoid irrelevant detail. Lectures Covered: This assignment covers Lecture # 01 - 06 Deadline Your assignment must be uploaded/submitted at or before 13/11/2019. Assignment Statement: In mathematics Prime is a number which can be only divisible by 1 and itself. Examples of prime numbers are, 1 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 etc. When these numbers get large, then it is very difficult to manually identify them as to be prime or not prime. For example the numbers like, 443 and 44371 cannot easily identify as Prime. There may be many algorithms which can be written for the identification of a number to be prime or not prime. Question No 01: (Marks: 10) You are required to design (write) a simple algorithm (Only Pseudo code) which can identify a number to be Prime or Not Prime. Question No 02: (Marks: 10) You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 01. =====================================Ended======================================= For any query about the assignment, contact at CS502@vu.edu.pk GOOD LUCK
CS502 - Fundamentals of Algorithms
CS502 Quiz 1 Solution and Discussion
zareenZ
Opening Dec 11, 2019 Closing Dec 12, 2019
CS502 - Fundamentals of Algorithms

CS502 Assignment No. 02 Solution and Discussion

Scheduled Pinned Locked Moved Solved CS502 - Fundamentals of Algorithms
cs502assignment 2solutiondiscussionfall 2019
6 Posts 1 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • zareenZ Offline
    zareenZ Offline
    zareen
    Cyberian's Gold
    wrote on last edited by
    #1

    Assignment No. 02
    SEMESTER Fall 2019
    CS502- Fundamentals of Algorithms
    Total Marks: 20

    Due Date: 27/11/2019
    Instructions
    Please read the following instructions carefully before solving & submitting assignment:
    It should be clear that your assignment will not get any credit if:
    • The assignment is submitted after due date.
    • The submitted assignment does not open or file corrupt.
    • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
    • Student ID is not mentioned in the assignment File or name of file is other than student ID.
    • The assignment is not submitted in .doc or .docx format.
    Uploading instructions
    Your submission must include:

    • Assignment should be in .doc or .docx format.
    • Save your assignment with your ID (e.g. bx180200786.doc).
    Assignment submission through email is NOT acceptable
    Objective
    The objective of this assignment is
    • To give basic knowledge and understanding of Algorithms.
    • To be able to design sorting algorithms.
    • To be able to understand and calculate the complexity of algorithms.

    Note:
    Your answer must follow the below given specifications.
    • Font style: “Times New Roman”
    • Font color: “Black”
    • Font size: “12”
    • Bold for heading only.
    • Font in Italic is not allowed at all.
    • No formatting or bullets are allowed to use.
    • Your answer should be precise and to the point, avoid irrelevant detail.

    Lectures Covered: This assignment covers Lecture # 09 - 14
    Deadline
    Your assignment must be uploaded/submitted at or before 27/11/2019.

    Assignment diagram:

    0e4a496c-d936-4a99-ac0c-2e198ae8fc43-image.png
    Consider the given diagram having an unsorted array and its sorting procedure through dry run. You are required to answer the following questions.

    Question No 01: (Marks: 5)
    You are required to determine (write down the name) the algorithm being used while sorting the above given array.

    Question No 02: (Marks: 7)
    You are required to design (write) the algorithm (Only Pseudo code) determined in Question 1.

    Question No 03: (Marks: 8)
    You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 02.

    =====================================Ended=======================================

    For any query about the assignment, contact at CS502@vu.edu.pk

    GOOD LUCK

    Discussion is right way to get Solution of the every assignment, Quiz and GDB.
    We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
    Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
    %(red)[NOTE: Don't copy or replicating idea solutions.]
    Quiz Copy Solution
    Mid and Final Past Papers
    Live Chat

    zareenZ 3 Replies Last reply
    0
    • zareenZ zareen

      Assignment No. 02
      SEMESTER Fall 2019
      CS502- Fundamentals of Algorithms
      Total Marks: 20

      Due Date: 27/11/2019
      Instructions
      Please read the following instructions carefully before solving & submitting assignment:
      It should be clear that your assignment will not get any credit if:
      • The assignment is submitted after due date.
      • The submitted assignment does not open or file corrupt.
      • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
      • Student ID is not mentioned in the assignment File or name of file is other than student ID.
      • The assignment is not submitted in .doc or .docx format.
      Uploading instructions
      Your submission must include:

      • Assignment should be in .doc or .docx format.
      • Save your assignment with your ID (e.g. bx180200786.doc).
      Assignment submission through email is NOT acceptable
      Objective
      The objective of this assignment is
      • To give basic knowledge and understanding of Algorithms.
      • To be able to design sorting algorithms.
      • To be able to understand and calculate the complexity of algorithms.

      Note:
      Your answer must follow the below given specifications.
      • Font style: “Times New Roman”
      • Font color: “Black”
      • Font size: “12”
      • Bold for heading only.
      • Font in Italic is not allowed at all.
      • No formatting or bullets are allowed to use.
      • Your answer should be precise and to the point, avoid irrelevant detail.

      Lectures Covered: This assignment covers Lecture # 09 - 14
      Deadline
      Your assignment must be uploaded/submitted at or before 27/11/2019.

      Assignment diagram:

      0e4a496c-d936-4a99-ac0c-2e198ae8fc43-image.png
      Consider the given diagram having an unsorted array and its sorting procedure through dry run. You are required to answer the following questions.

      Question No 01: (Marks: 5)
      You are required to determine (write down the name) the algorithm being used while sorting the above given array.

      Question No 02: (Marks: 7)
      You are required to design (write) the algorithm (Only Pseudo code) determined in Question 1.

      Question No 03: (Marks: 8)
      You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 02.

      =====================================Ended=======================================

      For any query about the assignment, contact at CS502@vu.edu.pk

      GOOD LUCK

      zareenZ Offline
      zareenZ Offline
      zareen
      Cyberian's Gold
      wrote on last edited by zareen
      #3

      Solution:
      Question No. 01: The name of the algorithm being used for sorting the given array has given below.
      Selection sort
      Question No. 02: The Pseudo code for the algorithm used for sorting the given array has given below.

      Pseudo code:
      1 Selection sort (A)
      {
      2 For i 1 to A.lenght-1
      {
      3 imin i
      4 for j i+1 to A.length
      {
      5 If (A[j] < A[imin])
      Imin j
      }
      6 Temp A[i]
      7 A[i] A[imin]
      8 A[imin] Temp
      }
      }

      Question No. 03: The step by stem analysis of the algorithm designed in question 2 is as follow,

      The time taken by each statement (step) is given as follows,

      Selection sort (A) Cost Times
      {
      For i 1 to A.length-1 c1 n
      {
      imin i-------------------- c2 n-1
      for j i+1 to A.length
      { c3 n+n-1+…1=n(n+1)/2
      If (A[j] < A[imin])
      imin j
      }
      Temp A[i] c4 n-1
      A[i] A[imin] c5 n-1
      A[imin] Temp c6 n-1
      }
      }

      Total time T(n) can be calculated as follows,

      T(n)= c1n+c2(n-1)+c3(n(n+1)/2)+c4(n-1)+c5(n-1)+c6(n-1)
      c1n+c2n-c2+c3 (n2+n/2) +c4n-c4+c5n-c5+c6n-c6 collect the like terms
      c3n2/2+ (c1+c2+c3/2+c4+c5+c6) n + (-c2-c4-c5-c6)

      This is equivalent to a polynomial an2+bn+c
      Therefore T (n) = Big O (n2) by taking the highest order term of the equation.
      Note: a, b, c in polynomial represents constants
      // Ignoring constant terms

      T(n) = O (n2)

      Discussion is right way to get Solution of the every assignment, Quiz and GDB.
      We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
      Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
      %(red)[NOTE: Don't copy or replicating idea solutions.]
      Quiz Copy Solution
      Mid and Final Past Papers
      Live Chat

      1 Reply Last reply
      0
      • zareenZ Offline
        zareenZ Offline
        zareen
        Cyberian's Gold
        wrote on last edited by
        #2

        https://youtu.be/7T7QTy9z4CM

        Discussion is right way to get Solution of the every assignment, Quiz and GDB.
        We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
        Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
        %(red)[NOTE: Don't copy or replicating idea solutions.]
        Quiz Copy Solution
        Mid and Final Past Papers
        Live Chat

        1 Reply Last reply
        0
        • zareenZ zareen

          Assignment No. 02
          SEMESTER Fall 2019
          CS502- Fundamentals of Algorithms
          Total Marks: 20

          Due Date: 27/11/2019
          Instructions
          Please read the following instructions carefully before solving & submitting assignment:
          It should be clear that your assignment will not get any credit if:
          • The assignment is submitted after due date.
          • The submitted assignment does not open or file corrupt.
          • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
          • Student ID is not mentioned in the assignment File or name of file is other than student ID.
          • The assignment is not submitted in .doc or .docx format.
          Uploading instructions
          Your submission must include:

          • Assignment should be in .doc or .docx format.
          • Save your assignment with your ID (e.g. bx180200786.doc).
          Assignment submission through email is NOT acceptable
          Objective
          The objective of this assignment is
          • To give basic knowledge and understanding of Algorithms.
          • To be able to design sorting algorithms.
          • To be able to understand and calculate the complexity of algorithms.

          Note:
          Your answer must follow the below given specifications.
          • Font style: “Times New Roman”
          • Font color: “Black”
          • Font size: “12”
          • Bold for heading only.
          • Font in Italic is not allowed at all.
          • No formatting or bullets are allowed to use.
          • Your answer should be precise and to the point, avoid irrelevant detail.

          Lectures Covered: This assignment covers Lecture # 09 - 14
          Deadline
          Your assignment must be uploaded/submitted at or before 27/11/2019.

          Assignment diagram:

          0e4a496c-d936-4a99-ac0c-2e198ae8fc43-image.png
          Consider the given diagram having an unsorted array and its sorting procedure through dry run. You are required to answer the following questions.

          Question No 01: (Marks: 5)
          You are required to determine (write down the name) the algorithm being used while sorting the above given array.

          Question No 02: (Marks: 7)
          You are required to design (write) the algorithm (Only Pseudo code) determined in Question 1.

          Question No 03: (Marks: 8)
          You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 02.

          =====================================Ended=======================================

          For any query about the assignment, contact at CS502@vu.edu.pk

          GOOD LUCK

          zareenZ Offline
          zareenZ Offline
          zareen
          Cyberian's Gold
          wrote on last edited by zareen
          #3

          Solution:
          Question No. 01: The name of the algorithm being used for sorting the given array has given below.
          Selection sort
          Question No. 02: The Pseudo code for the algorithm used for sorting the given array has given below.

          Pseudo code:
          1 Selection sort (A)
          {
          2 For i 1 to A.lenght-1
          {
          3 imin i
          4 for j i+1 to A.length
          {
          5 If (A[j] < A[imin])
          Imin j
          }
          6 Temp A[i]
          7 A[i] A[imin]
          8 A[imin] Temp
          }
          }

          Question No. 03: The step by stem analysis of the algorithm designed in question 2 is as follow,

          The time taken by each statement (step) is given as follows,

          Selection sort (A) Cost Times
          {
          For i 1 to A.length-1 c1 n
          {
          imin i-------------------- c2 n-1
          for j i+1 to A.length
          { c3 n+n-1+…1=n(n+1)/2
          If (A[j] < A[imin])
          imin j
          }
          Temp A[i] c4 n-1
          A[i] A[imin] c5 n-1
          A[imin] Temp c6 n-1
          }
          }

          Total time T(n) can be calculated as follows,

          T(n)= c1n+c2(n-1)+c3(n(n+1)/2)+c4(n-1)+c5(n-1)+c6(n-1)
          c1n+c2n-c2+c3 (n2+n/2) +c4n-c4+c5n-c5+c6n-c6 collect the like terms
          c3n2/2+ (c1+c2+c3/2+c4+c5+c6) n + (-c2-c4-c5-c6)

          This is equivalent to a polynomial an2+bn+c
          Therefore T (n) = Big O (n2) by taking the highest order term of the equation.
          Note: a, b, c in polynomial represents constants
          // Ignoring constant terms

          T(n) = O (n2)

          Discussion is right way to get Solution of the every assignment, Quiz and GDB.
          We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
          Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
          %(red)[NOTE: Don't copy or replicating idea solutions.]
          Quiz Copy Solution
          Mid and Final Past Papers
          Live Chat

          1 Reply Last reply
          0
          • zareenZ zareen

            Assignment No. 02
            SEMESTER Fall 2019
            CS502- Fundamentals of Algorithms
            Total Marks: 20

            Due Date: 27/11/2019
            Instructions
            Please read the following instructions carefully before solving & submitting assignment:
            It should be clear that your assignment will not get any credit if:
            • The assignment is submitted after due date.
            • The submitted assignment does not open or file corrupt.
            • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
            • Student ID is not mentioned in the assignment File or name of file is other than student ID.
            • The assignment is not submitted in .doc or .docx format.
            Uploading instructions
            Your submission must include:

            • Assignment should be in .doc or .docx format.
            • Save your assignment with your ID (e.g. bx180200786.doc).
            Assignment submission through email is NOT acceptable
            Objective
            The objective of this assignment is
            • To give basic knowledge and understanding of Algorithms.
            • To be able to design sorting algorithms.
            • To be able to understand and calculate the complexity of algorithms.

            Note:
            Your answer must follow the below given specifications.
            • Font style: “Times New Roman”
            • Font color: “Black”
            • Font size: “12”
            • Bold for heading only.
            • Font in Italic is not allowed at all.
            • No formatting or bullets are allowed to use.
            • Your answer should be precise and to the point, avoid irrelevant detail.

            Lectures Covered: This assignment covers Lecture # 09 - 14
            Deadline
            Your assignment must be uploaded/submitted at or before 27/11/2019.

            Assignment diagram:

            0e4a496c-d936-4a99-ac0c-2e198ae8fc43-image.png
            Consider the given diagram having an unsorted array and its sorting procedure through dry run. You are required to answer the following questions.

            Question No 01: (Marks: 5)
            You are required to determine (write down the name) the algorithm being used while sorting the above given array.

            Question No 02: (Marks: 7)
            You are required to design (write) the algorithm (Only Pseudo code) determined in Question 1.

            Question No 03: (Marks: 8)
            You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 02.

            =====================================Ended=======================================

            For any query about the assignment, contact at CS502@vu.edu.pk

            GOOD LUCK

            zareenZ Offline
            zareenZ Offline
            zareen
            Cyberian's Gold
            wrote on last edited by
            #4

            @zareen said in CS502 Assignment No. 02 Solution and Discussion:

            You are required to design (write) the algorithm (Only Pseudo code) determined in Question 1.

            Selectionsort (A , n)
            {
            For (i=0 to n-1)                                             
            {
            min  =  i      C1                         
            For (  j = i+1 to n-1)                                         
            {                                                             
            C2
            }
            C3
            }
            }
            

            Discussion is right way to get Solution of the every assignment, Quiz and GDB.
            We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
            Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
            %(red)[NOTE: Don't copy or replicating idea solutions.]
            Quiz Copy Solution
            Mid and Final Past Papers
            Live Chat

            1 Reply Last reply
            0
            • zareenZ zareen

              Assignment No. 02
              SEMESTER Fall 2019
              CS502- Fundamentals of Algorithms
              Total Marks: 20

              Due Date: 27/11/2019
              Instructions
              Please read the following instructions carefully before solving & submitting assignment:
              It should be clear that your assignment will not get any credit if:
              • The assignment is submitted after due date.
              • The submitted assignment does not open or file corrupt.
              • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
              • Student ID is not mentioned in the assignment File or name of file is other than student ID.
              • The assignment is not submitted in .doc or .docx format.
              Uploading instructions
              Your submission must include:

              • Assignment should be in .doc or .docx format.
              • Save your assignment with your ID (e.g. bx180200786.doc).
              Assignment submission through email is NOT acceptable
              Objective
              The objective of this assignment is
              • To give basic knowledge and understanding of Algorithms.
              • To be able to design sorting algorithms.
              • To be able to understand and calculate the complexity of algorithms.

              Note:
              Your answer must follow the below given specifications.
              • Font style: “Times New Roman”
              • Font color: “Black”
              • Font size: “12”
              • Bold for heading only.
              • Font in Italic is not allowed at all.
              • No formatting or bullets are allowed to use.
              • Your answer should be precise and to the point, avoid irrelevant detail.

              Lectures Covered: This assignment covers Lecture # 09 - 14
              Deadline
              Your assignment must be uploaded/submitted at or before 27/11/2019.

              Assignment diagram:

              0e4a496c-d936-4a99-ac0c-2e198ae8fc43-image.png
              Consider the given diagram having an unsorted array and its sorting procedure through dry run. You are required to answer the following questions.

              Question No 01: (Marks: 5)
              You are required to determine (write down the name) the algorithm being used while sorting the above given array.

              Question No 02: (Marks: 7)
              You are required to design (write) the algorithm (Only Pseudo code) determined in Question 1.

              Question No 03: (Marks: 8)
              You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 02.

              =====================================Ended=======================================

              For any query about the assignment, contact at CS502@vu.edu.pk

              GOOD LUCK

              zareenZ Offline
              zareenZ Offline
              zareen
              Cyberian's Gold
              wrote on last edited by
              #5

              @zareen said in CS502 Assignment No. 02 Solution and Discussion:

              You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 02.

              ANS:
              C1 =  (n-1)
              C2 = (n-1)+(n-2)+…+1
                 =  
              C3 = (n-1)
              T(n) = (n-1) . C1 +  . C2 +  (n-1)C3
              T(n) = an2 + bn + c
              Here a,b and c are constants in term of C1, C2 and C3
              T(n) = O(n2)
              
              

              Discussion is right way to get Solution of the every assignment, Quiz and GDB.
              We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
              Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
              %(red)[NOTE: Don't copy or replicating idea solutions.]
              Quiz Copy Solution
              Mid and Final Past Papers
              Live Chat

              1 Reply Last reply
              0
              • zareenZ Offline
                zareenZ Offline
                zareen
                Cyberian's Gold
                wrote on last edited by
                #6

                Solution:
                Question No. 01: The name of the algorithm being used for sorting the given array has given below.
                Selection sort
                Question No. 02: The Pseudo code for the algorithm used for sorting the given array has given below.

                Pseudo code:
                1 Selection sort (A)
                {
                2 For i 1 to A.lenght-1
                {
                3 imin i
                4 for j i+1 to A.length
                {
                5 If (A[j] < A[imin])
                Imin j
                }
                6 Temp A[i]
                7 A[i] A[imin]
                8 A[imin] Temp
                }
                }

                Question No. 03: The step by stem analysis of the algorithm designed in question 2 is as follow,

                The time taken by each statement (step) is given as follows,

                b8c2d4d9-76e3-4841-94a7-e8c1a8202f51-image.png

                Selection sort (A) Cost Times

                {
                For i 1 to A.length-1 |c1 | n
                {
                imin i--------------------> c2 n-1
                for j i+1 to A.length
                { c3 n+n-1+…1=n(n+1)/2
                If (A[j] < A[imin])
                imin j
                }
                Temp A[i] c4 n-1
                A[i] A[imin] c5 n-1
                A[imin] Temp c6 n-1
                }
                }

                Total time T(n) can be calculated as follows,

                T(n)= c1n+c2(n-1)+c3(n(n+1)/2)+c4(n-1)+c5(n-1)+c6(n-1)
                c1n+c2n-c2+c3 (n2+n/2) +c4n-c4+c5n-c5+c6n-c6 collect the like terms
                c3n2/2+ (c1+c2+c3/2+c4+c5+c6) n + (-c2-c4-c5-c6)

                This is equivalent to a polynomial an2+bn+c
                Therefore T (n) = Big O (n2) by taking the highest order term of the equation.
                Note: a, b, c in polynomial represents constants

                // Ignoring constant terms

                T(n) = O (n2)

                Discussion is right way to get Solution of the every assignment, Quiz and GDB.
                We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
                Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
                %(red)[NOTE: Don't copy or replicating idea solutions.]
                Quiz Copy Solution
                Mid and Final Past Papers
                Live Chat

                1 Reply Last reply
                0

                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                How to Build a $1,000/Month PAK VS BAN Live Live Cricket Streaming
                File Sharing
                Earn with File Sharing

                3

                Online

                3.0k

                Users

                2.8k

                Topics

                8.2k

                Posts
                solution
                1235
                discussion
                1195
                fall 2019
                813
                assignment 1
                428
                assignment 2
                294
                spring 2020
                265
                gdb 1
                238
                assignment 3
                79
                • PM. IMRAN KHAN
                  undefined
                  4
                  1
                  4.0k

                • Are the vaccines halal or not?
                  undefined
                  4
                  1
                  3.8k

                • All Subjects MidTerm and Final Term Solved Paper Links Attached Please check moaaz past papers
                  zaasmiZ
                  zaasmi
                  3
                  26
                  75.1k

                • CS614 GDB Solution and Discussion
                  M
                  moaaz
                  3
                  3
                  8.1k

                • How can I receive Reputation earning from Cyberian? 100% Discount on Fee
                  Y
                  ygytyh
                  3
                  28
                  23.9k
                Farhan ZahidF
                Farhan Zahid
                Ali AdnanA
                Ali Adnan
                | |
                Copyright © 2010-26 RUP Technologies LLC. USA | Contributors
                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Pro Blog
                • Users
                • Groups
                • Unsolved
                • Solved