Solved by Expert Tutors
Solved by Expert Tutors
Question

Question:<br/>How to design a function in Python, bubble_sort, which

takes as argument a Python list ip_list that stores IP (Internet Protocol) address.
You should count how many times each IP appears and store the information (IP, occurrence number) into a dictionary ip_dict. Then return a list of unique IPs whose occurrence number is in the descendingorder by sorting the ip_dict.
Note: 1) You are required to use Bubble Sort algorithm 2) You can assume that each IP appears in a different frequency.
The IP format we use here is IPV4 like x.x.x.x (0 &lt;= x &lt;= 255)      
Ip_list example:
["10.15.25.30", "10.15.25.30", "10.15.25.30", "10.15.25.32", "10.15.25.32", "10.15.25.31"]


ip_dict example:
{"10.15.25.30":3, "10.15.20.31":1 , "10.50.25.32": 2}
 
After sorting, the function should return:
["10.15.20.30", "10.15.20.32", "10.50.25.31"]

Step-by-step answer

ec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulviacinia pulvi

amet, c

gue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consec




Donec

output.PNG

output.PNG
r

Subscribe to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question