
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Define a function compress : lists(T) → lists(T) that accepts a list argument (of some generic type T) and returns a list without any subsequent redundancies, e.g. compress(⟨a, a, b, b, b, c, c, a, b⟩) = ⟨a, b, c, a, b⟩
1. Transform the definition into a computable function.
2. Define f recursively.
3. Unfold your definition for compress(⟨a, a, b, b, c, a⟩).
4. (PROGRAMMING) Please map your definition into a Common LISP function. Place your code in file compress.lisp. The code should behave as follows:
> (compress ’(a a a b c d d e))
(A B C D E)
> (compress ’())
NIL
> (compress ’(a b c c c a))
(A B C A)
> (compress ’(a a b b c c c c a b b))
(A B C A B)
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a java program class for a singly linked list with Insertion from head, tail and middlearrow_forwardImplement an Abstract Data Type Polynomial having single variable, implemented using Singly Linked List having following functions with the given prototype: 1. void initPolynomial (Polynomial *P, char *s, int n) ; The function creates a polynomial P from the given string s of length n. 2. Polynomial * addPolynomial(Polynomial P1, Polynomial P2); The function adds two polynomials P1 and P2 and returns a pointer of type Polynomial. 3. void displayPolynomial(Polynomial P, char var); The function displays the polynomial in a well formatted form. using c languagearrow_forward4. Define a polymorphic function of type: shimmy :: [a] -> a -> [a] which takes an input list and another value (of the same type as the input list's elements) and outputs a list based on the input list, but where every element is preceded by and followed by the second input. For example shimmy [1,2,3] 0 = [0,1,0,2,0,3,0] and shimmy 0 0 = [0]arrow_forward
- Can somebody tell me the answer to this?arrow_forwardDesign an implementation of an Abstract Data Type consisting of a set with the following operations: insert(S, x) Insert x into the set S. delete(S, x) Delete x fromthe set S. member(S, x) Return true if x ∈ S, false otherwise. position(S, x) Return the number of elements of S less than x. concatenate(S, T) Set S to the union of S and T, assuming every element in S is smaller than every element of T. All operations involving n-element sets are to take time O(log n).arrow_forwardQ3 QuickSort Given the QuickSort implementation from class, provide an 18-element list that will take the least number of recursive calls of QuickSort to complete. As a counter-example, here is a list that will cause QuickSort to make the MOST number of recursive calls: public static List input() { return Accaxsaslist(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } wwwwwww And here's the QuickSort algorithm, for convenience: algorithm QuickSart Input: lists of integers 1st of size N Output: new list with the elements of lat in sorted order if N < 2 return st pivot Jat[N-1] left = new empty list right = new empty list for index = 0, 1, 2, if lst[i]<= pivot left.add(lat[i]) = else N-2 right add(lat[i]) return QuickSort(left) + [pivot] + QuickSort (right)arrow_forward
- Write a C++ program that: (1) defines and implements a hash class that constructs a 15 element array (may be implemented using a vector, a deque, or a list, if you prefer, (using the STL implementations), storing strings, using the following hash function: ((first_letter) + (last_letter) - (second_letter))% 15 (2) the driver program should: a. query the user for ten words and store them using the hash technique described above. b. print out the contents of each position of the array (or vector, deque, or whatever you used), showing vacant as well as filled positions. Remember, only 10 of the 15 positions will be filled. c. repeatedly query the user for a target word, hash the word, check for its inclusion in the list of stored words, and report the result. Continue doing this task until the user signals to stop (establish a sentinel condition).arrow_forwardcreate a javascript function and show it working that none( list, predicate ) This function accepts a list of elements and a predicate function (i.e. a function of a single input that returns either true or false). The method returns true if none of the elements in the list satisfy the predicate; otherwise the function returns false. Examples none( [ 0, 1, 2, 3 ], (x) => x > 1 ) => false none( [ 1, 2, 3, 4 ], (x) => x < 0 ) => true none( [ 'a', [], 3, false, null ], (x) => typeof x == 'function' ) => truearrow_forwardWrite a LISP function f10 that finds the intersection of two lists. The intersection meansthe common elements of the two lists. Example: (f10 ‘(a (a b) c d) ‘(b(a b) d)) returns ((a b) d) CAN ONLY USE CAR AND CDR AND RECURSION SETQ AND DO LIST CANT BE USEDarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education