Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

C++

I have code:

#include <bitset>
#include <fstream>
#include <iostream>
#include <string>

using namespace std;
const std::string MORSE_CODE[] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."};
const char MORSE_DELIM = ' ';

string decodeMorse(const string& morse) {
    string message;
    string word;
    bitset<8> bits;
    int bitIndex = 0;

    for (char c : morse) {
        if (c == MORSE_DELIM) {
            int letterIndex = -1;
            for (int i = 0; i < 26; ++i) {
                if (word == MORSE_CODE[i]) {
                    letterIndex = i;
                    break;
                }
            }
            if (letterIndex != -1) {
                bits.set(bitIndex, letterIndex & 1);
                ++bitIndex;
                bits.set(bitIndex, (letterIndex >> 1) & 1);
                ++bitIndex;
                bits.set(bitIndex, (letterIndex >> 2) & 1);
                ++bitIndex;
                bits.set(bitIndex, (letterIndex >> 3) & 1);
                ++bitIndex;
            }
            else if (word.empty()) {
                bits.set(bitIndex, 0);
                ++bitIndex;
            }
            word.clear();
        }
        else {
            word.push_back(c);
        }
    }
    if (!word.empty()) {
        int letterIndex = -1;
        for (int i = 0; i < 26; ++i) {
            if (word == MORSE_CODE[i]) {
                letterIndex = i;
                break;
            }
        }
        if (letterIndex != -1) {
            bits.set(bitIndex, letterIndex & 1);
            ++bitIndex;
            bits.set(bitIndex, (letterIndex >> 1) & 1);
            ++bitIndex;
            bits.set(bitIndex, (letterIndex >> 2) & 1);
            ++bitIndex;
            bits.set(bitIndex, (letterIndex >> 3) & 1);
            ++bitIndex;
        }
        else {
            bits.set(bitIndex, 0);
            ++bitIndex;
        }
    }
    for (int i = 0; i < bitIndex; i += 8) {
        char ch = static_cast<char>(bits.to_ulong());
        message.push_back(ch);
        bits.reset();
    }
    return message;
}

Please help me write int main(){} to read the file below. Write a Tuple Search algorithm designed by yourself to find a character in the file.

Bin.bin when open with Visual Studio

RI…‰&!:¢E(šQ…¥9‰Š‰Ù…E%ŠD‰Ž¡˜¢J*”ª9I*5F#T¦4ª#¦(˜¨M˜TRX¤H˜ê)„”’b9baQbbE‰Š‰™:Š¢6bb$HhÒ¨"aN¡R˜II&#†(b"cEM¢*‰Šˆêˆ˜å&&dê*ˆêˆš%ˆhå&(HÒ¨˜TRX¤H˜Ù…Fˆé…I*ˆÙ…E‘†ŽF9¢‘‰&5)&ˆ¨é*!£TcJ¢9%…I¢hTÔ¢¢¢…F*4TÒ¨EEF:Ò¨Žh‘#•EXj…T¨äa£‰&&†SZ…T¨™“”ª(š#¨JF†R†5$J¢‘(f*9h劢‰¡R¡RXªNDâI‰¢¨‘M˜Tš&ˆXކ9ŠŠ¡EF”èa¢‰‘iN¢¨HNT‘H¨ê‰¢hEF”äa£J¢N¢‘¨¨…’’I¡”Ô’bbˆh™“’˜H˜Ö&$h¤‘(ac¡ŽUbª¡iN¢¨$¤Xªª(Xª:†b¨TTš5$J¢‘(f*:aRc“¨ª&J‰™4ª#f)%‰¢4ª!EJ’4TÚ…J„TbfNI¡*…JEŠ£RI…‰&!9bh‘†!£EN¡)NF¢¡&$fRDª!I†b£‘6¢bF"ŠŽ‘Š*H˜¨¡E¥:Š¢9†b%„†ŽNTTj9J¢5$¨¨‘˜ª)*!£¡Š„¡)5JcHf*†&…E†S”ª(š#ª"cª)*‰häD†!£ª$˜©$˜hæ‰%:†b¨TTš&däMJ¨ª#j!bF9baQbbE¡…Ž¡R˜II&#ENX˜†Š„Ò¨ŽR$J¢&9hÚ(hå…J„X˜‘¢’DŽQRa“¡HHT˜TšI™:Ò¨Ž$˜šNUaªR£ª$R‰¡åEJ†J£š(a˜T𿉅I‰Ra”ZS”ª"b:Š¢9I*:©&Š’:Ò¨Ž¢EˆáŠ’‰…F†–&%HfiM*ˆéŠ&*¤™’¢fNJ&6ˆ¦!ŠˆêJ„…&dê*ˆØTI‰¡”å&:…Ja%$˜Ž˜T˜ä剅E‰‰ÑS¡¢J)†S†!FS’‰†bbJa&dꉢhEF6!¤NQRa’9R„¨èb¡&)†D¡QŽh‘¨T˜‘&E¥9J¢†b¨å‰…J’†ˆh䉅F$¤J‰&!˜ªTšN˜T˜Ø’¢I™:Š¢9¢94‰Ò¨‘9I*4’¡’9J¨Ú"¤‰¡RX¡…*ˆê)„”’b:aRcJ¢5ŠJ$a˜ŽF6aQ„˜Tš:†R¡!JR˜Ò¨Ž†
bh¡b¨M˜TQIhäa£š)’cQQ¢’hŠR˜Ò¨ŽIaRhš5(¨¨¡QЉ™9J¢4¡HZSaS¨f*…EI¢£I)*„ê)„”’b8ab†"&(aaiN¡SJ¢4‰Ô…ˆ˜¨ê‰4Tå&5JDäa”剅F¢h…*5F4ª"‰RQ‰™:¢E(šQލ‰Šˆš)Ž¢X†bŠb†bI¢he6aQ†bI‰5F:…Ja%$˜6ˆHf¨e*âbaRb£‘†9ˆf*H˜èb˜T˜RD¡Qކ96aQIb‘"cf&$¨ª&dÚ…Dª4ª*#‰¢†£”‰ˆÙ‰ŠFb‰&¢’b†4ª#’XTš&…NU%SRŠŠŠZS”ª(f*9*aQ‰)£b(š9&¨I…F9hÚŠE¡häš&(cEM*ˆÔTTbfN¨‘J&„Tcš"˜MJ¡*ˆÔ¡£•EXZ…T¨ÑS”T˜dècJ¢9bbŠ’DŽ¢„T˜™“¨ª#f)…JF!£J¢6aQIbFN¨¡b¨‰Ra¢&:…Ja%$˜Ž†9TU…¨jŽF8¨I‰¢ŠŠ¢:¢E(šQ!˜ªTš(ŠŽUSe"IŠŽh‘"bfOª$R‰¡å$¨Ò¨ŽbŠ%Š!„Õ)ޤ’b…JJލTaRb¡iN†‰¢‘¢†6$¨’£†‘˜‰a(TbI£¨–$f#‘˜NII&&d剈¨™“j$˜‘˜dÕ‰“–&"¢Hhꈘå(J£J¢9bb*(h†‰&Hh’hÕ)Ž˜˜ˆhTS¡Ž•RU¢f@

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education