performance – Sorting Algorithms Optimisation Python

def MinimumSwaps(Queue):
        MinSwaps = 0
        for i in range(len(Queue) - 1):
            if Queue(i) != i+1:
                for j in range(i+1,len(Queue)):
                    if Queue(j) == i+1:
                        Queue(i), Queue(j) = Queue(j), Queue(i)
                        MinSwaps += 1
                        break
            else:
                continue
        return MinSwaps

def main():
    Result = MinimumSwaps((7, 1, 3, 2, 4, 5, 6))
    print(Result)  
if __name__ == "__main__":
    main()

The question: You are given an unordered array consisting of consecutive integers (1, 2, 3, …, n) without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order.

The issue is that what I have provided is inefficient and fails on very large arrays, however Ive tried to optimise it as much as I can and im not aware of another technique to use. This question is likely related to a particular sorting algorithm but is there any way to modify the above code to make it faster?

seo – How important is an informative URL for search engine optimisation?

I found a similar question here which gave this as a duplicate, but it deals specifically with parameters in the URL, whereas I am interested in the URL disregarding query strings.

For example, how much of a difference would it make for the same article to be of form:

www.example.com/how-to-mow-the-lawn-without-getting-wet-feet

vs

www.example.com/articles/238483

If it’s easy to implement the former, should it be done, or does it make little/no difference?

complexity theory – Decision vs Optimisation Problem in P

If a decision problem is in P, is the associated optimization problem then also efficiently solvable?

I always thought that this is the case but according to Wikipedia page on Decision Problems the complexity of a decision and function problem might differ and to me a function problem was always a special case of an optimization problem, hence I was under the impression that if the decision problem is efficiently decidable the same applies to the corresponding optimization problem.

cluster analysis – Bellman equation optimisation problem

I have a system which maps nodes to states, each node sate mapping is associated with a reward….now I have random rolled out games that I use to get the states, and then assign nodes randomly to each…given this , how would I optimize the association of nodes to states according to the bellman equation…as in I assume that there is a best next set of nodes for each state node pair in the dataset. And I need to find these successor best node states from the data by clustering of some sort…does this make any sense

WordPress speed optimisation based on GTMetrix ranking for $10

WordPress speed optimisation based on GTMetrix ranking

Is your WordPress site running slow? Did you know that speed of your website directly affects search engine rankings? Faster websites have better search engine positions.

What’s included in the gig:

  • Reducing TTFB (time to first byte) by enabling page caching
  • Minifying and combining CSS and JavaScript
  • Setting expiry headers
  • Enabling Gzip compression
  • Leverage browser caching
  • Optimizing all images without quality loss
  • Enabling CloudFlare or similar CDN (Content Delivery Network) for your website to enhance response time for static content

Some of the above options require installation of a plugin. On VPS and dedicated servers some additional packages might need to be installed in order to get best performance.

Full report of installed plugins and additional packages on the server will be provided.

Design and functionality of your website will not be affected.

.(tagsToTranslate)wordpress(t)speed(t)optimisation

Tweepy & Django performance optimisation

I had to create a project for academic purposes that gets all friends and follower of a user, stores them on a mongoDB, then displays them on a table. I used django and plain html but when I tried my friend’s account (230 contacts) it took 3 mins to load. That’s a lot cause supposly my app should have some scalability, eg be able to handle accounts with 100k + contacts.Here is my code.

from twitter_auth.apiKeys import *
import tweepy
from manager.models import Contact


def get_api(user):
    access_tokens = user.social_auth 
        .filter(provider='twitter')(0) 
        .extra_data('access_token')

    auth = tweepy.OAuthHandler(
        SOCIAL_AUTH_TWITTER_KEY,
        SOCIAL_AUTH_TWITTER_SECRET
    )

    auth.set_access_token(
        access_tokens('oauth_token'),
        access_tokens('oauth_token_secret')
    )

    api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

    return api


def get_user_contacts(user):
    # Setup Twitter API instance of logged User
    api = get_api(user)
    me = api.me()

    # Set number of contacts fetched per call Max:200
    count = 200

    # Fetch logged User's friends into a list
    friends = tweepy.Cursor(api.friends, me.screen_name, count=count).items()
    # friends = api.friends(me.screen_name, count=10)
    friend_list = ()
    for i in friends:
        friend_list.append(i)

    # Fetch logged User's followers into a list
    followers = tweepy.Cursor(api.followers, me.screen_name, count=count).items()
    # followers = api.followers(me.screen_name, count=10)
    follower_list = ()
    for j in followers:
        follower_list.append(j)

    existing_contacts = Contact.objects.filter(user=user)
    for contact in existing_contacts:
        if contact not in friend_list and contact not in follower_list:
            contact.delete()

    # Start iterating friend list fetched from Twitter API
    for friend in friend_list:
        # Initialize Contact Object
        temp_friend = Contact(
            twitter_id=friend.id,
            profile_image_url=friend.profile_image_url_https,
            screen_name=friend.screen_name,
            name=friend.name,
            followers_count=friend.followers_count,
            friends_count=friend.friends_count,
            statuses_count=friend.statuses_count,
            description=friend.description,
            location=friend.location,
            friendship_status=1,
            protected_status=friend.protected,
            user=user
        )
        # Check if entry is just Friend (1) or Friend & Follower (3)
        if friend in follower_list:
            temp_friend.friendship_status = 3

        # Check if current friend already exists in DB
        existing_friend = Contact.objects.filter(screen_name=friend.screen_name, user=user)

        if existing_friend:
            # Update Contact info
            existing_friend.update(
                profile_image_url=friend.profile_image_url_https,
                name=friend.name,
                followers_count=friend.followers_count,
                friends_count=friend.friends_count,
                statuses_count=friend.statuses_count,
                description=friend.description,
                location=friend.location,
                protected_status=friend.protected,
            )
            # Check if existing Contact followed back
            # Case: Have followed back so friendship status updates to (3)
            if existing_friend in follower_list:
                existing_friend.update(
                    friendship_status=3
                )
            # Case: Have not followed back so friendship status remains unchanged(1)
        else:
            temp_friend.save()

    # Start iterating follower list fetched from Twitter API
    for follower in follower_list:
        # Initialize Contact Object
        temp_follower = Contact(
            twitter_id=follower.id,
            profile_image_url=follower.profile_image_url_https,
            screen_name=follower.screen_name,
            name=follower.name,
            followers_count=follower.followers_count,
            friends_count=follower.friends_count,
            statuses_count=follower.statuses_count,
            description=follower.description,
            location=follower.location,
            friendship_status=2,
            protected_status=follower.protected,
            user=user
        )

        # Check if current follower already exists in DB
        existing_follower = Contact.objects.filter(twitter_id=follower.id, user=user)
        if existing_follower:
            # Update Contact info
            existing_follower.update(
                profile_image_url=follower.profile_image_url_https,
                name=follower.name,
                followers_count=follower.followers_count,
                friends_count=follower.friends_count,
                statuses_count=follower.statuses_count,
                description=follower.description,
                location=follower.location,
                protected_status=follower.protected,
            )
            # Check if user followed back existing the existing follower
            # Case: Have followed back so friendship status updates to (3)
            if existing_follower in friend_list:
                existing_follower.update(
                    friendship_status=3
                )
            # Case: Have not followed back so friendship status remains unchanged(2)
        else:
            temp_follower.save()


def get_user_tweets(user, id):
    api = get_api(user)

    tweet_list = api.user_timeline(id=id, count=2)

    return tweet_list
```

Please how does the YouTube Search Engine Optimisation Tool work because I am really stuck???

I want to know more about the YouTube search engine optimisation tools because am stuck in my channel.

calculus – How do I solve this question using optimisation?

The question is as follows:

Near East Inc., a corporate gift specialist, just received an order of 500 hampers. To meet the order, the general manager is considering engaging inexperienced packers who each charges a flat fee of $100. Each packer can pack 2 hampers in 1 hour. A supervisor who charges $10 per hour will also be engaged. A flat commission fee of $50 is applicable. What is the minimum manpower cost if this option is chosen?

Thank you!