Time complexity of code running at most summation(N) times in a loop

Let’s say I have a JavaScript loop iterating over input of size N. Let’s say all elements in N are unique, so the includes method traverses the entire output array on each loop iteration:

let out = [] for (x in N) }   if (!out.includes(x)) {     out.push(x)   } } 

The worst case runtime of the code inside the loop seems to be not O(N), but the summation of N, which is substantially faster.

Is this properly expressed as O(N^2) overall or is there a standard way to convey the faster asymptotic behavior given the fact that the output array is only of size N at the end of the loop?

How to loop multiple images on a single page/post

Hello I am using openseadragon, and I was able to reference one image on my page via openseadragon, but how to do loop more images so I can have 5 more images on the page…

Currently I have this as my javascript

     var imagePath = "/wp-content/uploads/" + $  ('#materials-osd').attr('data-image');     var viewer = OpenSeadragon({         id: "materials-osd",         prefixUrl: "/wp-content/plugins/zoom-openseadragon/images/",         tileSources: {             type: "image",...
Code (markup):

How to loop multiple images on a single page/post

how to write a function to show lists of running processes or while loop functions in php

Please i have a while loop function that am using to insert data into my database periodically, for some reasons i found out that while loop is more easy to use than cronjob, while loop runs without anyone having to visit the site, but my problem is that once a while loop is started it keeps running even if you delete the codes from your php file, it keeps running, and if you amend the code with new values and start it again both the old loop and the new one keeps running. My question is how can i write a php function that will list out all current running loop processes in my webhost or server and then use another code to end or stop or remove it from running?

Below is my code

$  date = date('Y-h-m H:i:s'); $  counter = 0; while($  counter < 10){      $  wpdb->query("INSERT INTO a_boy (username, password) VALUES ('cash', $  date)");     $  counter + 1;     sleep(60); } 

Revolution Slider – Hide a layer forever at the end of first loop

Is it possible to hide a layer once and forever in Revolution Slider? I’d like to show a logo only at the beginning of the slider (when you first load that page) and then hide it once and forever, keeping the rest of the slider go in loop as usual… I can’t find a “Play Once” option for layer animations anywhere…

Best Way to loop through huge mongodb collection every minute?

I need to loop through mongodb collection EVERY MINUTE which will be huge in future, I have to loop through each object and then use some if else conditions and then perform an http post request inside IF condition. I am planning to use https://www.npmjs.com/package/node-cron this library for the purpose that will run a task every minute. In this task, i will get a mongodb collection, loop through all the objects using ForEach loop and then do some actions using if else conditions. Is this approach okay or there is better/efficient way?

WordPress posts in the loop not stacking side by side

I was following a wp theme developement tutorial but somehow the posts from main loop and projects are not showing side by side ..although all other css works fine here is my code

front-page.php

<?php get_header();?>      <div id="banner">         <h1>&lt;GTCoding/&gt;</h1>         <h3>Learn coding from scratch</h3>     </div>      <main>         <a href="<?php echo site_url('/blog');?>">             <h2 class="section-heading">All Blogs</h2>         </a>        <?php         $  args =  array(          'post_type' => 'post',          'posts_per_page' => 2         );         $  blogposts = new WP_Query($  args);          while($  blogposts->have_posts()){             $  blogposts->the_post();        ?>         <section>             <div class="card">                 <div class="card-image">                     <a href="<?php echo the_permalink(); ?>">                         <img src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="<?php echo the_permalink(); ?>">                         <h3><?php the_title(); ?></h3>                     </a>                     <p>                        <?php echo wp_trim_words(get_the_excerpt(),30); ?>                     </p>                     <a href="<?php echo the_permalink(); ?>" class="btn-readmore">Read more</a>                 </div>             </div>           <?php }              wp_reset_query();            ?>          </section>          <a href="<?php echo site_url('/projects');?>">             <h2 class="section-heading">All Projects</h2>         </a>          <?php         $  args =  array(          'post_type' => 'project',          'posts_per_page' => 2         );         $  projects = new WP_Query($  args);          while($  projects->have_posts()){             $  projects->the_post();        ?>         <section>             <div class="card">                 <div class="card-image">                     <a href="<?php echo the_permalink(); ?>">                         <img src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="<?php echo the_permalink(); ?>">                         <h3><?php the_title(); ?></h3>                     </a>                     <p>                        <?php echo wp_trim_words(get_the_excerpt(),30); ?>                     </p>                     <a href="<?php echo the_permalink(); ?>" class="btn-readmore">Read more</a>                 </div>             </div>           <?php }              wp_reset_query();            ?>          </section>          <h2 class="section-heading">Source Code</h2>          <section id="section-source">             <p>                 Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum neque qui delectus ad dolor blanditiis perferendis praesentium                 consectetur aut sed provident obcaecati aspernatur perspiciatis, dolores nobis pariatur ipsum vel corrupti!             </p>             <a href="#" class="btn-readmore">GitHub Profile</a>         </section>        <?php get_footer();?> 

header.php

<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <meta http-equiv="X-UA-Compatible" content="ie=edge">     <title>GTCoding</title>     <?php wp_head(); ?> </head>  <body>     <div id="slideout-menu">         <ul>             <li>                 <a href="<?php echo site_url('');?>">Home</a>             </li>             <li>                 <a href="<?php echo site_url('/blog');?>">Blog</a>             </li>             <li>                 <a href="<?php echo site_url('/projects');?>">Projects</a>             </li>             <li>                 <a href="<?php echo site_url('/about');?>">About</a>             </li>             <li>                 <input type="text" placeholder="Search Here">             </li>         </ul>     </div>      <nav>         <div id="logo-img">             <a href="#">                 <img src="<?php echo get_template_directory_uri();?>/img/logo.png" alt="GTCoding Logo">             </a>         </div>         <div id="menu-icon">             <i class="fas fa-bars"></i>         </div>         <ul>             <li>                 <a class="active" href="<?php echo site_url('');?>">Home</a>             </li>             <li>                 <a href="<?php echo site_url('/blog');?>">Blog</a>             </li>             <li>                 <a href="<?php echo site_url('/projects');?>">Projects</a>             </li>             <li>                 <a href="<?php echo site_url('/about');?>">About</a>             </li>             <li>                 <div id="search-icon">                     <i class="fas fa-search"></i>                 </div>             </li>         </ul>     </nav>      <div id="searchbox">         <input type="text" placeholder="Search Here">     </div> 

footer.php

  <footer>             <div id="left-footer">                 <h3>Quick Links</h3>                 <p>                     <ul>                         <li>                             <a href="index.html">Home</a>                         </li>                         <li>                             <a href="about.html">About</a>                         </li>                         <li>                             <a href="#">Privacy Policy</a>                         </li>                         <li>                             <a href="blogslist.html">Blogs</a>                         </li>                         <li>                             <a href="blogslist.html">Projects</a>                         </li>                         <li>                             <a href="#">Contact</a>                         </li>                     </ul>                 </p>             </div>              <div id="right-footer">                 <h3>Follow us on</h3>                 <div id="social-media-footer">                     <ul>                         <li>                             <a href="#">                                 <i class="fab fa-facebook"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-youtube"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-github"></i>                             </a>                         </li>                     </ul>                 </div>                 <p>This website is developed by GTCoding</p>             </div>         </footer>      </main>   <?php wp_footer();?> </body>  </html> 

enter image description here

it should show like this

enter image description here

here is my index.html code

<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <meta http-equiv="X-UA-Compatible" content="ie=edge">     <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt"         crossorigin="anonymous">     <link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Roboto+Slab" rel="stylesheet">     <link rel="stylesheet" href="style.css">     <title>GTCoding</title> </head>  <body>     <div id="slideout-menu">         <ul>             <li>                 <a href="index.html">Home</a>             </li>             <li>                 <a href="blogslist.html">Blog</a>             </li>             <li>                 <a href="blogslist.html">Projects</a>             </li>             <li>                 <a href="about.html">About</a>             </li>             <li>                 <input type="text" placeholder="Search Here">             </li>         </ul>     </div>      <nav>         <div id="logo-img">             <a href="#">                 <img src="img/logo.png" alt="GTCoding Logo">             </a>         </div>         <div id="menu-icon">             <i class="fas fa-bars"></i>         </div>         <ul>             <li>                 <a class="active" href="index.html">Home</a>             </li>             <li>                 <a href="blogslist.html">Blog</a>             </li>             <li>                 <a href="blogslist.html">Projects</a>             </li>             <li>                 <a href="about.html">About</a>             </li>             <li>                 <div id="search-icon">                     <i class="fas fa-search"></i>                 </div>             </li>         </ul>     </nav>      <div id="searchbox">         <input type="text" placeholder="Search Here">     </div>      <div id="banner">         <h1>&lt;GTCoding/&gt;</h1>         <h3>Learn coding from scratch</h3>     </div>      <main>         <a href="blogslist.html">             <h2 class="section-heading">All Blogs</h2>         </a>          <section>             <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/1.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Blog Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>              <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/2.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Blog Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>         </section>          <a href="blogslist.html">             <h2 class="section-heading">All Projects</h2>         </a>          <section>             <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/3.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Project Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>              <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/4.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Project Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>         </section>          <h2 class="section-heading">Source Code</h2>          <section id="section-source">             <p>                 Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum neque qui delectus ad dolor blanditiis perferendis praesentium                 consectetur aut sed provident obcaecati aspernatur perspiciatis, dolores nobis pariatur ipsum vel corrupti!             </p>             <a href="#" class="btn-readmore">GitHub Profile</a>         </section>          <footer>             <div id="left-footer">                 <h3>Quick Links</h3>                 <p>                     <ul>                         <li>                             <a href="index.html">Home</a>                         </li>                         <li>                             <a href="about.html">About</a>                         </li>                         <li>                             <a href="#">Privacy Policy</a>                         </li>                         <li>                             <a href="blogslist.html">Blogs</a>                         </li>                         <li>                             <a href="blogslist.html">Projects</a>                         </li>                         <li>                             <a href="#">Contact</a>                         </li>                     </ul>                 </p>             </div>              <div id="right-footer">                 <h3>Follow us on</h3>                 <div id="social-media-footer">                     <ul>                         <li>                             <a href="#">                                 <i class="fab fa-facebook"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-youtube"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-github"></i>                             </a>                         </li>                     </ul>                 </div>                 <p>This website is developed by GTCoding</p>             </div>         </footer>      </main>      <script src="main.js"></script> </body>  </html> 

Amount of expected loop iterations when searching an array by random index

Lets say we have an array A of size n. It has 1 as its first index and n as its last index. It contains a value x, with x occurring k times in A where 1<=k<=n

If we have a search algorithm like so:

while true:   i := random(1, n)   if A[i] == x     break 

random(a,b) picks a number uniformly from a to b

From this we know that the chances of finding x and terminating the program is k/n with each iteration. However what I would like to know is what would be the expected value for the number of iterations or more specifically the amount of times the array was accessed in this program given the array A as described above.

How does the hardware of a while loop work?

I know get how logical operators for if logic gates work, but I am trying to understand how while loops fit into that picture. I realize that this question is a bit vague. It all started because I was wondering if one could write a while-loop with a series of if statements. Then I realized there had to be something deeper in our programming languages.

for each loop in vector passed to a function error

in for loop it shows error that: begin was not declared in the scope.

my code:

#include<bits/stdc++.h>  using namespace std; vector<int> v[1001];  void dfs(int i,vector<int> &v) {     for(int c: v[i])     cout<<c; }  int main() {      int n,e,a,b;     cin>>n>>e;      vector<bool> vis(n+1,0);     vector<int> v[n+1];     while(e--) {         cin>>a>>b;         v[a].push_back(b);         v[b].push_back(a);     }     dfs(1,v); }