Question

In: Computer Science

Please explain answer a little bit I'm familiar with these all topics..just give hint with your...

Please explain answer a little bit I'm familiar with these all topics..just give hint with your answer... the first question is quick sort
1) (13 points)
 Show the results of pivoting the following array using  0.34 as the pivot value.
 0.34 -4.62  8.50 -5.45  7.80  8.19  9.72 -2.85  0.88 -0.07 -0.28 -3.58
2)(13 points)
Draw the graph defined by the following adjacency matrix:

     ?         ?         ?         ?       -4.8      -2.3       9.7       3.9  
     ?         ?       -4.6       5.1      -8.5       2.0      -2.2      -9.1  
     ?       -4.6         ?      -2.9      -2.4      -3.2       2.3         ?  
     ?        5.1      -2.9        ?         ?        9.0       7.4       5.0  
   -4.8      -8.5      -2.4        ?         ?       -5.0      -6.9      -9.6  
   -2.3       2.0      -3.2       9.0      -5.0         ?       5.9      -7.7  
    9.7      -2.2       2.3       7.4      -6.9       5.9         ?      -3.8 

3)(13 points)
Show the order in which the vertices of the graph from question 3 will be visited in a depth first traversal.
Use 0, 1, 2, 3, 4, 5, 6, 7 as the names of the nodes, and assume that the neighbors of any node are given in left to right order across the matrix.
4)(13 points)
Consider the following adjacency matrix.
?    4.0  3.0  1.0  
4.0  ?    8.0  1.0
3.0  8.0  ?    5.0
1.0  1.0  5.0  ?
Use Kruskal's algorithm to find a minimum spanning tree.
 
    3.9      -9.1        ?        5.0      -9.6      -7.7      -3.8         ?

Solutions

Expert Solution

Note-:Question 2 and 3 here are not valid,in order to create a graph,you must have a square matrix.However , the matrix given in question is 7*8.However , i will try to answer the other 2 questions.

1)Quick sort is an algorithm based on divide and concur.The idea is to separate the array into sub arrays until all arrays have only 1 elements using linear time.In above problem we are using 0.34 as pivot and divide the list into 2 parts:-

step1-:Take two variables i and j pointing to starting index of the list excluding pivot
step2-:if arr[i]<pivot , swap a[i] and a[j] , increment i , increment j
if not,increment j

In above problem->
 0.34 -4.62  8.50 -5.45  7.80  8.19  9.72 -2.85  0.88 -0.07 -0.28 -3.58

after 1st iteration-:

1st part->-4.62,-5.45,-2.85,-0.07,-0.28,-3.58

2nd part->8.50,0.88,7.80,8.19,9.72

i)i=1,j=1,

0.34>-4.62,(swap a[i],a[j])i++,j++

ii)i=2,j=2,

0.34<8.50,j++(i unchanged)

iii)i=2,j=3,

0.34<-5.45,swap i,j(i++,j++)

keep on repeating till j==size of array

for next iteration, pivot is the 1st element in both sub parts,when all the sub parts all sorted they are merged again to create a sorted array

4)Kruksal algorithm for minimum spanning tree is used to fing minimum subgraph of a graph that connects all vertices.this is based on greedy algorithm.

step1: Sort all the edges in increasing order of their weight.
step2: Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If cycle is not formed, include this edge. Else, discard it.
step3: Repeat step 2 until there are V-1 edges in the spanning tree.

given graph is:

the graph here has 4 vertices, so number of edges in spanning tree will be 3:

weigt of edges are->

1: between 1 and 4

1: between 2 and 4

3: between 1 and 3

4: between 1 and 2

5: between 3 and 4

8: between 2 and 3

So, we take edge with weight 1 between 1 and 4,since no cycle is formed we will include it

graph is--> (1)-----------------(4)

1  

now,edge between 2 and 4 with weight 1,since no cycle is formed we will include it

graph is--> (1)------------(4)-------------(2)

1 1

now with weight 3 between 1 and 3,since no cycle is formed we will include it

minimum spanning tree is-:

(3)------------(1)--------------(4)-------------(2)

3 1 1


Related Solutions

Please write the answer on a computer not on a paper I'm a little confused as...
Please write the answer on a computer not on a paper I'm a little confused as to what exactly I'm researching and writing about. If someone could break it down and give me a few minor examples so I can structure the essay around it I would really appreciate it: (Intel 80x86, ARM, MIPS R4000 )Write a two page report on the similarities and differences are of these architectures. Include in your report what you find interesting about the architectures...
Can you explain a bit more how BBC (Behavior Based Costings) works? I'm not as familiar...
Can you explain a bit more how BBC (Behavior Based Costings) works? I'm not as familiar with this costings sytem.
please answer all questions and explain in detail and do not give the definition. Explain the...
please answer all questions and explain in detail and do not give the definition. Explain the importance of "environmental scanning" when making marketing plans
PLEASE ANSWER ALL 1.5 If all rainbow colors are to be represented by a unique bit...
PLEASE ANSWER ALL 1.5 If all rainbow colors are to be represented by a unique bit pattern, how many bits would be needed to store each color? Why? 1.6 What is the usage of each of the following elements in a Graphical User Interface (GUI)? a. windows b. icons c. buttons d. sliders 1.10 What is the significance of a Domain Name System (DNS) in the Internet? What would happen without a DNS? 1.12 Explain the difference between a web...
Answer true or false to the following questions please explain your answers and answer all please  ...
Answer true or false to the following questions please explain your answers and answer all please   1.The cytoplasmatic side of the integral membrane proteins is often glycosylated. 2. Cholesterol is more enriched at the outer leaflet of the plasma membrana 3.Inner leaflet of the plasma membrane is enriched with glycolipids. 4.Membrane proteins that pomp ions in and out of the cell have specific Km values. 5. A symport would function as an antiport if its orientation in the membrane were...
pls explain the answer a little bit, thank you. Let A ∈ Mm,n(F) and let TA...
pls explain the answer a little bit, thank you. Let A ∈ Mm,n(F) and let TA : F n → F m be the corresponding linear map (see (1.2)). (a) Prove that A has a left inverse if and only if TA is injective. (b) Prove that A has a right inverse if and only if TA is surjective. (c) Prove that A has a two-sided inverse if and only if TA is an isomorphism.
Please answer all If you can't answer all then please don't answer just one question. i...
Please answer all If you can't answer all then please don't answer just one question. i need all 2. You would like to buy a house in in 16 years and estimate that you will need a deposit of $73,014. You plan to make bi-weekly deposits into an account that you hope will earn 7.05%. How much do you have to deposit every two weeks? 3. You have accumulated $1,085.55 in debt by buying things on Amazon during quarantine.  The minimum...
Please EXPLAIN your answer, do not just state the answer. 72) Which of the following compounds...
Please EXPLAIN your answer, do not just state the answer. 72) Which of the following compounds contains the longest carbon-carbon single bond? A) allene B) 1, 3-butadiyne C) 1, 3-butadiene D) propyne E) ethane
Please do not just give the answer. Please also explain how you got them. Thanks! 1....
Please do not just give the answer. Please also explain how you got them. Thanks! 1. Which of the following is not a valid method of applying LCNRV: A. logical categories of inventory (i.e. product line) B. the entire inventory C. inventory items to be sold within the next year D. individual inventory items E. None of the answer choices are correct 2. Which of the following would not require the company to account for the change retrospectively? A. From...
In your words explain what is RACE. Please make sure not to limit your answer just...
In your words explain what is RACE. Please make sure not to limit your answer just to the physical features. I'm interested to read your opinion on how you think the concept have been utilized at the social, economic and government levels.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT