Write a function min2 to compute the second smallest of number of an integer list. You may assume the list has at least 2 numbers and all numbers are distinct.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

USING SML PROGRAMMING

  1. Write a function min2 to compute the second  smallest of number of an integer list. You may assume the list has at least 2 numbers and all numbers are distinct. 
    min2([1,3,2,5,4]) → 2
Expert Solution
Step 1

ANSWER:

Second and Smallest of Number:

A Simple Solution is to sort the exhibit in expanding request.

The initial two components in arranged exhibit would be two smallest components.

Time intricacy of this arrangement is O(n Log n).

A Better Solution is to examine the cluster two times. In first crossing track down the base component.

Allow this component to be x. In second crossing, find the smallest component more noteworthy than x.

Time intricacy of this arrangement is O(n).

The above arrangement requires two crossings of info cluster.

An Efficient Solution can track down the base two components in a single crossing.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY