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*"a9I*5F#T¦4a#¦( ̃ ̈M ̃TRX¤H ̃ê)„"’b9baQbbE‰Š‰TM:Š6ドルbb$HhÒ ̈"aN¡R ̃II&#†(b"cEM¢*‰Šˆêˆ ̃å&&dê*ˆêˆš%ˆhå&(HÒ ̈ ̃TRX¤H ̃Ù...Fˆé...I*ˆÙ...E‘†ŽF9¢‘‰&5)&ˆ ̈é*!£TcJ9ドル%...I¢hTÔ¢¢¢...F*4TÒ ̈EEF:Ò ̈Žh‘#•EXj...T ̈äa£‰&&†SZ...T ̈TM""a(š# ̈JF†R†5$J¢‘(f*9h劢‰¡R¡RXaNDâI‰¢ ̈‘M ̃Tš&ˆXކ9ŠŠ¡EF"èa¢‰‘iN¢ ̈HNT‘H ̈ꉢhEF"äa£J¢N¢‘ ̈ ̈...’’I¡"Ô’bbˆhTM"’ ̃H ̃Ö&$h¤‘(ac¡ŽUba¡iN¢ ̈$¤Xaa(Xa:†b ̈TTš5$J¢‘(f*:aRc" ̈a&J‰TM4a#f)%‰4ドルa!EJ’4TÚ...J„TbfNI¡*...JEŠ£RI...‰&!9bh‘†!£EN¡)NF¢¡&$fRDa!I†b£‘6¢bF"ŠŽ‘Š*H ̃ ̈¡E\:Š9ドル†b%„†ŽNTTj9J5ドル$ ̈ ̈‘ ̃a)*!£¡Š„¡)5JcHf*†&...E†S"a(š#a"ca)*‰häD†!£a$ ̃©$ ̃hæ‰%:†b ̈TTš&däMJ ̈a#j!bF9baQbbE¡...Ž¡R ̃II&#ENX ̃†Š„Ò ̈ŽR$J¢&9hÚ(hå...J„X ̃‘¢’DŽQRa"¡HHT ̃TšITM:Ò ̈Ž$ ̃šNUaaR£a$R‰¡åEJ†J£š(a ̃Tšæ‰...I‰Ra"ZS"a"b:Š9ドルI*:©&Š’:Ò ̈Ž¢EˆáŠ’‰...F†–&%HfiM*ˆéŠ&*¤TM’¢fNJ&6ˆ¦!ŠˆêJ„...&dê*ˆØTI‰¡"å&:...Ja%$ ̃Ž ̃T ̃äå‰...E‰‰ÑS¡¢J)†S†!FS’‰†bbJa&dꉢhEF6!¤NQRa’9R„ ̈èb¡&)†D¡QŽh‘ ̈T ̃‘&E9円J¢†b ̈å‰...J’†ˆhä‰...F$¤J‰&! ̃aTšN ̃T ̃Ø’¢ITM:Š9ドル¢94‰Ò ̈‘9I*4’¡’9J ̈Ú"¤‰¡RX¡...*ˆê)„"’b:aRcJ5ドルŠJ$a ̃ŽF6aQ„ ̃Tš:†R¡!JR ̃Ò ̈ކ
bh¡b ̈M ̃TQIhäa£š)’cQQ¢’hŠR ̃Ò ̈ŽIaRhš5( ̈ ̈¡QЉTM9J4ドル¡HZSaS ̈f*...EI¢£I)*„ê)„"’b8ab†"&(aaiN¡SJ4ドル‰Ô...ˆ ̃ ̈ê‰4Tå&5JDäa"å‰...F¢h...*5F4a"‰RQ‰TM:¢E(šQŽ ̈‰Šˆš)Ž¢X†bŠb†bI¢he6aQ†bI‰5F:...Ja%$ ̃6ˆHf ̈e*âbaRb£‘†9ˆf*H ̃èb ̃T ̃RD¡Qކ96aQIb‘"cf&$ ̈a&dÚ...Da4a*#‰¢†£"‰ˆÙ‰ŠFb‰&¢’b†4a#’XTš&...NU%SRŠŠŠZS"a(f*9*aQ‰)£b(š9& ̈I...F9hÚŠE¡häš&(cEM*ˆÔTTbfN ̈‘J&„Tcš" ̃MJ¡*ˆÔ¡£•EXZ...T ̈ÑS"T ̃dècJ9ドルbbŠ’DŽ¢„T ̃TM" ̈a#f)...JF!£J6ドルaQIbFN ̈¡b ̈‰Ra¢&:...Ja%$ ̃ކ9TU... ̈jŽF8 ̈I‰¢ŠŠ¢:¢E(šQ! ̃aTš(ŠŽUSe"IŠŽh‘"bfOa$R‰¡å$ ̈Ò ̈ŽbŠ%Š!„Õ)ޤ’b...JJŽ ̈TaRb¡iN†‰¢‘¢†6$ ̈’£†‘ ̃‰a(TbI£ ̈–$f#‘ ̃NII&&d剈 ̈TM"j$ ̃‘ ̃dÕ‰"–&"¢Hhêˆ ̃å(J£J9ドルbb*(h†‰&Hh’hÕ)Ž ̃ ̃ˆhTS¡Ž•RU¢f@

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
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