Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def remove3big(list1, N): final_list = [] list1.sort() for i in range(0, N): max1 = 0 for j in range(len(list1)): if list1[j] > max1: max1 =

image text in transcribed
def remove3big(list1, N):
final_list = []
list1.sort()
for i in range(0, N):
max1 = 0
for j in range(len(list1)):
if list1[j] > max1:
max1 = list1[j];
final_list.append(max1)
list1 = [i for i in list1 if i not in final_list]
print(list1)
list1 = [1,2,3,4,5,6,6,5,4,3,2,1]
N =3
remove3big(list1,3)
3. The list L contains arbitrary numbers. Write a Prolog program remove3big(L,R) that returns the reduced list R which contains those elements of list L that are different from three largest values in L. In other words, it is necessary to eliminate all duplicates of the three largest values in L and the remaining elements should be stored in R. You can use all Prolog functions. Example: ?- remove3big([1,2,3,4,5,6,6,5,4,3,2,1), R). R = [1, 1, 2, 2, 3, 3]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

Would CBT be a good choice for Anoushka?

Answered: 1 week ago

Question

Describe the nature of negative messages.

Answered: 1 week ago