Another run is faster
It's no secret that the processor has a cache with 1,2,3
levels. But what will be the efficiency when we run the same
code twice. From a philosophical point of view, there is an
ideal situation when the time complexity of the second run
will be close to O(1). But the ideal situation is
unattainable. It was decided to conduct an experiment.
It is proposed to prepare arrays ranging in size from 1 megabyte to 20 megabytes. And for these arrays, it is proposed to run the same algorithm twice in a pipe.
The results of the comparison are shown in the diagram.
Conclusion.
The cache greatly facilitates re-computation. If the computing structures are small, then the gain can be up to x2 for a given processor.
It is proposed to prepare arrays ranging in size from 1 megabyte to 20 megabytes. And for these arrays, it is proposed to run the same algorithm twice in a pipe.
data[0] = 17
for i := 1; i < size; i++ {
data[i] = data[i-1] + 3
}
code in github.com
The results of the comparison are shown in the diagram.
Conclusion.
The cache greatly facilitates re-computation. If the computing structures are small, then the gain can be up to x2 for a given processor.
How to use the program Data Entry
This video demonstrates the basic capabilities of the Data Entry program.
- Creating interval numeric and other variables.
- The verifiable entry of variable values.
- Exporting to SPSS. Save the template with a password.
Little Linux experimentation with laptop AN515-46-R70A
I wanted to install linux on my acer laptop. But my laptop
has BIOS version 1.03. In
official site
I saw that the latest version is 1.07. There is a Windows
executable file only. Looking ahead: I tried to use
wine
in Ubuntu to run this file. But it failed. Firstly, I had to
install Windows. But which USB boot solution is chosen? On
the advice of my friend, I have chosen
Ventoy. As it turned out, the BIOS firmware should reboot in DOS
mode without the Windows environment. It was funny. After
Ventoy prepared the flash card on Ubuntu, it looked as
empty, but it was bootable. I saved the ISO Windows and
Linux files for the installations to the flash drive through
a simple copy operation. After these manipulations, I
started experimenting. I downloaded the new versions of
Endless OS, Linux Mint, Ubuntu and Manjaro. I read that
someone sells a laptop like mine with Endless OS. Therefore,
I hoped to install this operating system successfully. But
it failed. This OS is not even started. Then I successfully
started Manjaro. I really like this OS. This operating
system is very ergonomic and functional. But I saw it not
worked with my Wi-Fi device. I connected to LAN and did not
see the problem in time. There are many options for choosing
a Linux kernel in Manjaro. I have chosen version 6.0.0, but
Wi-Fi didn't work yet. Linux Mint has the similar problem.
Besides, the web camera didn't work either. I decided to
stop on Ubuntu. Because, the Wi-Fi worked well.
Conclusions
Linux | Endless OS | Linux Mint | Manjaro | Ubuntu |
---|---|---|---|---|
ISO | eos-eos4.0-amd64-amd64.220406-204708.base.iso | linuxmint-21-cinnamon-64bit.iso | manjaro-kde-21.3.7-220816-linux515.iso | ubuntu-22.04.1-desktop-amd64.iso |
Mediatek MT7921 WiFi | No information | Not working | Not working | Working |
Internal web camera Quanta ACER HD User Facing | No information | Not working | Not working | Not working |
External web camera Sunplus Innovation Aukey-PC-LM1E | No information | No information | No information | Working |
Longest Substring Without Repeating Characters
/*
#----------------------------------------------------------------------------------------------#
# #
# version 0.0.1 #
# https://leetcode.com/problems/longest-substring-without-repeating-characters/submissions/ #
# #
# Aleksiej Ostrowski, 2020 #
# #
# https://aleksiej.com #
# #
#----------------------------------------------------------------------------------------------#
*/
#include <string>
#include <iostream>
int max(const int a, const int b) {
if (a > b) return a; else return b;
}
class Solution {
public:
int lengthOfLongestSubstring(std::string s) {
auto len_s = s.length();
if (len_s <= 1) return len_s;
std::string t;
int max_len = -1;
int i = 0;
for (;;) {
auto found = t.find(s[i]);
if (found != -1) t = t.substr(found + 1);
t += s[i];
max_len = max(max_len, t.length());
std::cout << "i = " << i << " s[" << i << "] = " << s[i] << " max_len = " << max_len << " string = " << t << std::endl;
if (++i >= len_s) break;
}
return max_len;
}
};
int main() {
// std::string s = "aabac"; // 3
// std::string s = "pwwkew"; // 3
// std::string s = "bbbbb"; // 1
// std::string s = " "; // 1
std::string s = "aab"; // 2
std::cout << "input " << s << std::endl;
auto S = Solution();
std::cout << S.lengthOfLongestSubstring(s) << std::endl;
return 0;
}