Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write two Lisp functions inspired from memory allocation methods that will be discussed in class. Both functions take two parameters: a list containing numbers and

image text in transcribed

Write two Lisp functions inspired from memory allocation methods that will be discussed in class. Both functions take two parameters: a list containing numbers and a simple value that we can assume to be a number. Both functions should return nil if they don't find what they are looking for. a. The first function should be called first-fit and it should return the first element in the list that is larger than or equal to the value. For example, (first-fit '(3 8 6 4 9) 5) should return 8. b.(*A3) The second should be called best-fit and it should return the element of the list that best fits the value. For this, you have to look for the smallest value in the list that is larger than or equal to the value. Do not use the built-in function sort, nor sort the list in some other way. The solution should be linear and sorting is worse than linear. For example, (best-fit '(3 8 6 4 9) 5) should return 6

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions