×
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 3.se - Problem 8e
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 3.se - Problem 8e

×

# 8E Devise an efficient algorithm for finding the second ISBN: 9780073383095 37

## Solution for problem 8E Chapter 3.SE

Discrete Mathematics and Its Applications | 7th Edition

• Textbook Solutions
• 2901 Step-by-step solutions solved by professors and subject experts
• Get 24/7 help from StudySoup virtual teaching assistants Discrete Mathematics and Its Applications | 7th Edition

4 5 1 341 Reviews
20
3
Problem 8E

?8E Devise an efficient algorithm for finding the second largest element in a sequence of ?n? elements and determine the worst-case complexity of your algorithm.

Step-by-Step Solution:

Solution Step 1 In this Question we have to write the best way to find the second largest number from the list of n elements. Algorithms second_largest_Num(num1, num2, num3, …………...set of integers) Assign a variable largest_num1 and largest_num2 then set it as 0 Now, initialize the loop For ( i = 0 ; i < size ; i++) where n is the number of element in the list. Check the largest number to the second largest number till size. if( element at ith position > largest_num1) then Largest_num2 := largest_num1 Largest_num1 := element at ith position Else if (element at ith position > largest_num2) then Largest_num2 := element at ith position return largest_num2 which is the second largest number.

Step 2 of 2

##### ISBN: 9780073383095

Unlock Textbook Solution